diff --git a/account.py b/account.py index 1d3ff2dba2..f1ca2b7b60 100644 --- a/account.py +++ b/account.py @@ -27,17 +27,19 @@ class Account(ModelSQL, ModelView): ('normal', 'Normal'), ], 'Type', required=True) root = fields.Many2One('analytic_account.account', 'Root', select=2, - domain=[('parent', '=', False)], - states={ - 'invisible': Equal(Eval('type'), 'root'), - 'required': Not(Equal(Eval('type'), 'root')), - }) + domain=[('parent', '=', False)], + states={ + 'invisible': Equal(Eval('type'), 'root'), + 'required': Not(Equal(Eval('type'), 'root')), + }, + depends=['type']) parent = fields.Many2One('analytic_account.account', 'Parent', select=2, - domain=[('parent', 'child_of', Eval('root'))], - states={ - 'invisible': Equal(Eval('type'), 'root'), - 'required': Not(Equal(Eval('type'), 'root')), - }) + domain=[('parent', 'child_of', Eval('root'))], + states={ + 'invisible': Equal(Eval('type'), 'root'), + 'required': Not(Equal(Eval('type'), 'root')), + }, + depends=['root', 'type']) childs = fields.One2Many('analytic_account.account', 'parent', 'Children') balance = fields.Function(fields.Numeric('Balance', digits=(16, Eval('currency_digits', 1)), depends=['currency_digits']), @@ -59,8 +61,9 @@ class Account(ModelSQL, ModelView): ('credit-debit', 'Credit - Debit'), ], 'Display Balance', required=True) mandatory = fields.Boolean('Mandatory', states={ - 'invisible': Not(Equal(Eval('type'), 'root')), - }) + 'invisible': Not(Equal(Eval('type'), 'root')), + }, + depends=['type']) def __init__(self): super(Account, self).__init__() diff --git a/tests/test_analytic_account.py b/tests/test_analytic_account.py index 0da5af78e7..40c212f608 100644 --- a/tests/test_analytic_account.py +++ b/tests/test_analytic_account.py @@ -10,7 +10,7 @@ if os.path.isdir(DIR): import unittest import trytond.tests.test_tryton -from trytond.tests.test_tryton import test_view +from trytond.tests.test_tryton import test_view, test_depends class AnalyticAccountTestCase(unittest.TestCase): @@ -27,6 +27,12 @@ class AnalyticAccountTestCase(unittest.TestCase): ''' test_view('analytic_account') + def test0006depends(self): + ''' + Test depends. + ''' + test_depends() + def suite(): suite = trytond.tests.test_tryton.suite() suite.addTests(unittest.TestLoader().loadTestsFromTestCase(