Raise error for account used only on the accessor

Because of the batch mode of Function field, the getter must not raise error
otherwise the error can be raised for a record that doesn't require the
account.
So we introduce an new kind of Function field which raise the error only at the
accessor level.

issue4087
review9531002
This commit is contained in:
Cédric Krier
2014-08-29 16:15:15 +02:00
parent 82e8f320b1
commit cf9b17a855
+8 -4
View File
@@ -4,6 +4,8 @@ from trytond.model import fields
from trytond.pyson import Eval
from trytond.pool import PoolMeta
from trytond.modules.account_product import MissingFunction
__all__ = ['Category', 'Template']
__metaclass__ = PoolMeta
@@ -20,8 +22,9 @@ class Category:
| Eval('account_parent')),
},
depends=['account_parent']))
account_cogs_used = fields.Function(fields.Many2One('account.account',
'Account Cost of Goods Sold Used'), 'get_account')
account_cogs_used = MissingFunction(fields.Many2One('account.account',
'Account Cost of Goods Sold Used'), 'missing_account',
'get_account')
class Template:
@@ -39,5 +42,6 @@ class Template:
help='This account will be used instead of the one defined '
'on the category.',
depends=['account_category', 'type']))
account_cogs_used = fields.Function(fields.Many2One('account.account',
'Account Cost of Goods Sold Used'), 'get_account')
account_cogs_used = MissingFunction(fields.Many2One('account.account',
'Account Cost of Goods Sold Used'), 'missing_account',
'get_account')