kassenbuchtyp: Feld 'feature'
This commit is contained in:
parent
db84bf7097
commit
82afd24c20
9 changed files with 68 additions and 0 deletions
9
book.py
9
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
|
||||
|
|
16
locale/de.po
16
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 #
|
||||
|
|
16
locale/en.po
16
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"
|
||||
|
|
|
@ -116,6 +116,9 @@ full copyright notices and license terms. -->
|
|||
<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>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_btype_general">
|
||||
<field name="text">General</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -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.",
|
||||
|
|
16
types.py
16
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
|
||||
"""
|
||||
|
|
|
@ -65,4 +65,5 @@ full copyright notices and license terms. -->
|
|||
</page>
|
||||
</notebook>
|
||||
|
||||
<field name="feature"/>
|
||||
</form>
|
||||
|
|
|
@ -7,4 +7,8 @@ full copyright notices and license terms. -->
|
|||
<field name="short"/>
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
|
||||
<label name="feature"/>
|
||||
<field name="feature"/>
|
||||
|
||||
</form>
|
||||
|
|
|
@ -5,4 +5,5 @@ full copyright notices and license terms. -->
|
|||
<tree>
|
||||
<field name="short"/>
|
||||
<field name="name"/>
|
||||
<field name="feature"/>
|
||||
</tree>
|
||||
|
|
Loading…
Reference in a new issue