kassenbuchtyp: Feld 'feature'

This commit is contained in:
Frederik Jaeckel 2022-12-21 19:12:39 +01:00
parent db84bf7097
commit 82afd24c20
9 changed files with 68 additions and 0 deletions

View file

@ -62,6 +62,8 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
Len(Eval('lines')) > 0, Len(Eval('lines')) > 0,
), ),
}, depends=DEPENDS+['lines']) }, depends=DEPENDS+['lines'])
feature = fields.Function(fields.Char(string='Feature', readonly=True,
states={'invisible': True}), 'on_change_with_feature')
owner = fields.Many2One(string='Owner', required=True, select=True, owner = fields.Many2One(string='Owner', required=True, select=True,
model_name='res.user', ondelete='SET NULL', model_name='res.user', ondelete='SET NULL',
states=STATES, depends=DEPENDS) states=STATES, depends=DEPENDS)
@ -325,6 +327,13 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
) )
return total return total
@fields.depends('btype')
def on_change_with_feature(self, name=None):
""" get feature-set
"""
if self.btype:
return self.btype.feature
@fields.depends('currency') @fields.depends('currency')
def on_change_with_currency_digits(self, name=None): def on_change_with_currency_digits(self, name=None):
""" currency of cashbook """ currency of cashbook

View file

@ -154,6 +154,10 @@ msgctxt "model:ir.message,text:msg_book_no_type_noopen"
msgid "The cash book '%(bookname)s' has no type and therefore cannot be opened." msgid "The cash book '%(bookname)s' has no type and therefore cannot be opened."
msgstr "Das Kassenbuch '%(bookname)s' hat keinen Typ und kann daher nicht geöffnet werden." msgstr "Das Kassenbuch '%(bookname)s' hat keinen Typ und kann daher nicht geöffnet werden."
msgctxt "model:ir.message,text:msg_btype_general"
msgid "General"
msgstr "Allgemein"
############# #############
# res.group # # res.group #
@ -594,6 +598,10 @@ msgctxt "field:cashbook.book,company_currency_digits:"
msgid "Currency Digits (Ref.)" msgid "Currency Digits (Ref.)"
msgstr "Nachkommastellen Währung (Ref.)" msgstr "Nachkommastellen Währung (Ref.)"
msgctxt "field:cashbook.book,feature:"
msgid "Feature"
msgstr "Merkmal"
################## ##################
# cashbook.split # # cashbook.split #
@ -994,6 +1002,14 @@ msgctxt "field:cashbook.type,company:"
msgid "Company" msgid "Company"
msgstr "Unternehmen" msgstr "Unternehmen"
msgctxt "field:cashbook.type,feature:"
msgid "Feature"
msgstr "Merkmal"
msgctxt "help:cashbook.type,feature:"
msgid "Select feature set of the Cashbook."
msgstr "Wählen Sie den Funktionsumfang des Kassenbuchs aus."
##################### #####################
# cashbook.category # # cashbook.category #

View file

@ -150,6 +150,10 @@ msgctxt "model:ir.message,text:msg_book_no_type_noopen"
msgid "The cash book '%(bookname)s' has no type and therefore cannot be opened." msgid "The cash book '%(bookname)s' has no type and therefore cannot be opened."
msgstr "The cash book '%(bookname)s' has no type and therefore cannot be opened." msgstr "The cash book '%(bookname)s' has no type and therefore cannot be opened."
msgctxt "model:ir.message,text:msg_btype_general"
msgid "General"
msgstr "General"
msgctxt "model:res.group,name:group_cashbook" msgctxt "model:res.group,name:group_cashbook"
msgid "Cashbook" msgid "Cashbook"
msgstr "Cashbook" msgstr "Cashbook"
@ -558,6 +562,10 @@ msgctxt "field:cashbook.book,company_currency_digits:"
msgid "Currency Digits (Ref.)" msgid "Currency Digits (Ref.)"
msgstr "Currency Digits (Ref.)" msgstr "Currency Digits (Ref.)"
msgctxt "field:cashbook.book,feature:"
msgid "Feature"
msgstr "Feature"
msgctxt "model:cashbook.split,name:" msgctxt "model:cashbook.split,name:"
msgid "Split booking line" msgid "Split booking line"
msgstr "Split booking line" msgstr "Split booking line"
@ -946,6 +954,14 @@ msgctxt "field:cashbook.type,company:"
msgid "Company" msgid "Company"
msgstr "Company" msgstr "Company"
msgctxt "field:cashbook.type,feature:"
msgid "Feature"
msgstr "Feature"
msgctxt "help:cashbook.type,feature:"
msgid "Select feature set of the Cashbook."
msgstr "Select feature set of the Cashbook."
msgctxt "model:cashbook.category,name:" msgctxt "model:cashbook.category,name:"
msgid "Category" msgid "Category"
msgstr "Category" msgstr "Category"

View file

@ -116,6 +116,9 @@ full copyright notices and license terms. -->
<record model="ir.message" id="msg_book_no_type_noopen"> <record model="ir.message" id="msg_book_no_type_noopen">
<field name="text">The cash book '%(bookname)s' has no type and therefore cannot be opened.</field> <field name="text">The cash book '%(bookname)s' has no type and therefore cannot be opened.</field>
</record> </record>
<record model="ir.message" id="msg_btype_general">
<field name="text">General</field>
</record>
</data> </data>
</tryton> </tryton>

View file

@ -255,6 +255,8 @@ class BookTestCase(ModuleTestCase):
}]) }])
self.assertEqual(book.name, 'Book 1') self.assertEqual(book.name, 'Book 1')
self.assertEqual(book.btype.rec_name, 'CAS - Cash') self.assertEqual(book.btype.rec_name, 'CAS - Cash')
self.assertEqual(book.btype.feature, 'gen')
self.assertEqual(book.feature, 'gen')
self.assertRaisesRegex(UserError, self.assertRaisesRegex(UserError,
"The type cannot be deleted on the cash book 'Book 1 | 1.00 usd | Open' because it still contains 1 lines.", "The type cannot be deleted on the cash book 'Book 1 | 1.00 usd | Open' because it still contains 1 lines.",

View file

@ -5,6 +5,7 @@
from trytond.model import ModelView, ModelSQL, fields, Unique from trytond.model import ModelView, ModelSQL, fields, Unique
from trytond.transaction import Transaction from trytond.transaction import Transaction
from trytond.i18n import gettext
class Type(ModelSQL, ModelView): class Type(ModelSQL, ModelView):
@ -15,6 +16,9 @@ class Type(ModelSQL, ModelView):
short = fields.Char(string='Abbreviation', required=True, size=3) short = fields.Char(string='Abbreviation', required=True, size=3)
company = fields.Many2One(string='Company', model_name='company.company', company = fields.Many2One(string='Company', model_name='company.company',
required=True, ondelete="RESTRICT") required=True, ondelete="RESTRICT")
feature = fields.Selection(string='Feature', required=True,
selection='get_sel_feature',
help='Select feature set of the Cashbook.')
@classmethod @classmethod
def __setup__(cls): def __setup__(cls):
@ -25,6 +29,18 @@ class Type(ModelSQL, ModelView):
('code_uniq', Unique(t, t.short), 'cashbook.msg_type_short_unique'), ('code_uniq', Unique(t, t.short), 'cashbook.msg_type_short_unique'),
]) ])
@classmethod
def default_feature(cls):
""" default: general
"""
return 'gen'
@classmethod
def get_sel_feature(cls):
""" get feature-modes
"""
return [('gen', gettext('cashbook.msg_btype_general'))]
def get_rec_name(self, name): def get_rec_name(self, name):
""" short + name """ short + name
""" """

View file

@ -65,4 +65,5 @@ full copyright notices and license terms. -->
</page> </page>
</notebook> </notebook>
<field name="feature"/>
</form> </form>

View file

@ -7,4 +7,8 @@ full copyright notices and license terms. -->
<field name="short"/> <field name="short"/>
<label name="name"/> <label name="name"/>
<field name="name"/> <field name="name"/>
<label name="feature"/>
<field name="feature"/>
</form> </form>

View file

@ -5,4 +5,5 @@ full copyright notices and license terms. -->
<tree> <tree>
<field name="short"/> <field name="short"/>
<field name="name"/> <field name="name"/>
<field name="feature"/>
</tree> </tree>