Fix account domain for the cases where move line is not defined

This commit is contained in:
Sergi Almacellas Abellana 2014-05-14 16:11:22 +02:00
parent dba2eeaa8b
commit 97b773929c
2 changed files with 11 additions and 4 deletions

View file

@ -7,7 +7,7 @@ from sql.conditionals import Coalesce
from trytond import backend
from trytond.model import ModelSQL, ModelView, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Or, PYSONEncoder
from trytond.pyson import Eval, Or, PYSONEncoder, If, Bool
from trytond.transaction import Transaction
from trytond.wizard import Wizard
@ -210,6 +210,15 @@ class AnalyticLine:
'required': Eval('state') != 'draft',
'readonly': Eval('state') != 'draft',
}
if not 'move_line' in cls.account.depends:
old_domain = cls.account.domain
company_domain = old_domain.pop()
cls.account.domain = [old_domain,
If(Bool(Eval('move_line', 0)),
company_domain,
[()])
]
cls.account.depends.append('move_line')
cls.currency_digits.on_change_with = ['currency']
cls._error_messages.update({
@ -248,7 +257,7 @@ class AnalyticLine:
table = TableHandler(cursor, cls, module_name)
is_sqlite = 'backend.sqlite.table.TableHandler' in str(TableHandler)
is_sqlite = 'backend.sqlite.table.TableHandler' in str(TableHandler)
# Migration from DB without this module
#table.not_null_action('move_line', action='remove') don't execute the
# action if the field is not defined in this module

View file

@ -358,11 +358,9 @@ def suite():
'scenario_account_reconciliation_rst')
for test in test_company.suite():
if test not in suite and test.id().split('.')[-1] not in exclude_tests:
print "Adding company test '%s'" % test.id().split('.')[-1]
suite.addTest(test)
for test in test_account.suite():
if test not in suite and test.id().split('.')[-1] not in exclude_tests:
print "Adding account test '%s'" % test.id().split('.')[-1]
suite.addTest(test)
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase))
return suite