kategorie: typ 'einnahme/ausgabe' - test muß noch
This commit is contained in:
parent
d57d76ba3b
commit
52ffa0536e
7 changed files with 95 additions and 1 deletions
22
line.py
22
line.py
|
@ -53,7 +53,13 @@ class Line(Workflow, ModelSQL, ModelView):
|
|||
states=STATES, depends=DEPENDS)
|
||||
category = fields.Many2One(string='Category', required=True,
|
||||
model_name='cashbook.category', ondelete='RESTRICT',
|
||||
states=STATES, depends=DEPENDS)
|
||||
states=STATES, depends=DEPENDS+['bookingtype'],
|
||||
domain=[
|
||||
If(
|
||||
Eval('bookingtype', '').in_(['in', 'mvin']),
|
||||
('cattype', '=', 'in'),
|
||||
('cattype', '=', 'out'),
|
||||
)])
|
||||
category_view = fields.Function(fields.Char(string='Category', readonly=True),
|
||||
'on_change_with_category_view', searcher='search_category_view')
|
||||
|
||||
|
@ -135,6 +141,20 @@ class Line(Workflow, ModelSQL, ModelView):
|
|||
"""
|
||||
pass
|
||||
|
||||
@fields.depends('bookingtype', 'category')
|
||||
def on_change_bookingtype(self):
|
||||
""" clear category if not valid type
|
||||
"""
|
||||
types = {
|
||||
'in': ['in', 'mvin'],
|
||||
'out': ['out', 'mvout'],
|
||||
}
|
||||
|
||||
if self.bookingtype:
|
||||
if self.category:
|
||||
if not self.bookingtype in types.get(self.category.cattype, ''):
|
||||
self.category = None
|
||||
|
||||
@classmethod
|
||||
def default_state(cls):
|
||||
""" default: edit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue