Add test for depends
This commit is contained in:
1 parent
747e7f455e
commit
2c04fd2e66
2 files changed
+22
-13
No files matched your search
+15
-12
@@ -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__()
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user