diff --git a/book.py b/book.py index f844bb8..19cefd8 100644 --- a/book.py +++ b/book.py @@ -62,6 +62,8 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView): Len(Eval('lines')) > 0, ), }, 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, model_name='res.user', ondelete='SET NULL', states=STATES, depends=DEPENDS) @@ -325,6 +327,13 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView): ) 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') def on_change_with_currency_digits(self, name=None): """ currency of cashbook diff --git a/locale/de.po b/locale/de.po index c772093..f458099 100644 --- a/locale/de.po +++ b/locale/de.po @@ -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." 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 # @@ -594,6 +598,10 @@ msgctxt "field:cashbook.book,company_currency_digits:" msgid "Currency Digits (Ref.)" msgstr "Nachkommastellen Währung (Ref.)" +msgctxt "field:cashbook.book,feature:" +msgid "Feature" +msgstr "Merkmal" + ################## # cashbook.split # @@ -994,6 +1002,14 @@ msgctxt "field:cashbook.type,company:" msgid "Company" 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 # diff --git a/locale/en.po b/locale/en.po index ccde331..88d9807 100644 --- a/locale/en.po +++ b/locale/en.po @@ -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." 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" msgid "Cashbook" msgstr "Cashbook" @@ -558,6 +562,10 @@ msgctxt "field:cashbook.book,company_currency_digits:" msgid "Currency Digits (Ref.)" msgstr "Currency Digits (Ref.)" +msgctxt "field:cashbook.book,feature:" +msgid "Feature" +msgstr "Feature" + msgctxt "model:cashbook.split,name:" msgid "Split booking line" msgstr "Split booking line" @@ -946,6 +954,14 @@ msgctxt "field:cashbook.type,company:" msgid "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:" msgid "Category" msgstr "Category" diff --git a/message.xml b/message.xml index 423b0c7..ed21703 100644 --- a/message.xml +++ b/message.xml @@ -116,6 +116,9 @@ full copyright notices and license terms. --> The cash book '%(bookname)s' has no type and therefore cannot be opened. + + General + diff --git a/tests/test_book.py b/tests/test_book.py index 878ebf2..bc83d60 100644 --- a/tests/test_book.py +++ b/tests/test_book.py @@ -255,6 +255,8 @@ class BookTestCase(ModuleTestCase): }]) self.assertEqual(book.name, 'Book 1') self.assertEqual(book.btype.rec_name, 'CAS - Cash') + self.assertEqual(book.btype.feature, 'gen') + self.assertEqual(book.feature, 'gen') self.assertRaisesRegex(UserError, "The type cannot be deleted on the cash book 'Book 1 | 1.00 usd | Open' because it still contains 1 lines.", diff --git a/types.py b/types.py index 7181cd2..a2554c4 100644 --- a/types.py +++ b/types.py @@ -5,6 +5,7 @@ from trytond.model import ModelView, ModelSQL, fields, Unique from trytond.transaction import Transaction +from trytond.i18n import gettext class Type(ModelSQL, ModelView): @@ -15,6 +16,9 @@ class Type(ModelSQL, ModelView): short = fields.Char(string='Abbreviation', required=True, size=3) company = fields.Many2One(string='Company', model_name='company.company', required=True, ondelete="RESTRICT") + feature = fields.Selection(string='Feature', required=True, + selection='get_sel_feature', + help='Select feature set of the Cashbook.') @classmethod def __setup__(cls): @@ -25,6 +29,18 @@ class Type(ModelSQL, ModelView): ('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): """ short + name """ diff --git a/view/book_form.xml b/view/book_form.xml index de1c6db..d971582 100644 --- a/view/book_form.xml +++ b/view/book_form.xml @@ -65,4 +65,5 @@ full copyright notices and license terms. --> + diff --git a/view/type_form.xml b/view/type_form.xml index bc002d7..16ddf9e 100644 --- a/view/type_form.xml +++ b/view/type_form.xml @@ -7,4 +7,8 @@ full copyright notices and license terms. -->