diff --git a/book.py b/book.py index fde854d..a3704ed 100644 --- a/book.py +++ b/book.py @@ -28,6 +28,9 @@ STATES2 = { ), 'invisible': ~Bool(Eval('btype')), } +STATES3 = {} +STATES3.update(STATES2) +STATES3['required'] = ~STATES2['invisible'] DEPENDS2 = ['state', 'btype'] sel_state_book = [ @@ -83,10 +86,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView): ('company', '=', Eval('company', -1)), ], ], - states={ - 'readonly': STATES2['readonly'], - 'required': Bool(Eval('btype')), - }, depends=DEPENDS2+['company']) + states=STATES3, depends=DEPENDS2+['company']) number_atcheck = fields.Boolean(string="number when 'Checking'", help="The numbering of the lines is done in the step Check. If the check mark is inactive, this happens with Done.", states=STATES2, depends=DEPENDS2) @@ -97,7 +97,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView): Bool(Eval('lines')), ), 'invisible': STATES2['invisible'], - 'required': Bool(Eval('btype')), + 'required': ~STATES2['invisible'], }, depends=DEPENDS2+['lines']) balance = fields.Function(fields.Numeric(string='Balance', readonly=True, digits=(16, Eval('currency_digits', 2)), @@ -110,7 +110,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView): Bool(Eval('lines', [])), ), 'invisible': STATES2['invisible'], - 'required': Bool(Eval('btype')), + 'required': ~STATES2['invisible'], }, depends=DEPENDS2+['lines']) currency_digits = fields.Function(fields.Integer(string='Currency Digits', readonly=True), 'on_change_with_currency_digits')