From 8abfb814383a3581682e110a26dfdaf70a10a640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 20 Oct 2013 20:43:08 +0200 Subject: [PATCH] Fix states of analytic account fields Set the same state of the real one2many and use a custom one for required. issue3012 review1151003 --- account.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/account.py b/account.py index faf8e2f9d1..05c388f64a 100644 --- a/account.py +++ b/account.py @@ -287,10 +287,15 @@ class Account(ModelSQL, ModelView): parent.remove(element_accounts) @classmethod - def analytic_accounts_fields_get(cls, field, fields_names=None): + def analytic_accounts_fields_get(cls, field, fields_names=None, + states=None, required_states=None): res = {} if fields_names is None: fields_names = [] + if states is None: + states = {} + + encoder = PYSONEncoder() root_accounts = cls.search([ ('parent', '=', None), @@ -299,7 +304,13 @@ class Account(ModelSQL, ModelView): name = 'analytic_account_' + str(account.id) if name in fields_names or not fields_names: res[name] = field.copy() - res[name]['required'] = account.mandatory + field_states = states.copy() + if account.mandatory: + if required_states: + field_states['required'] = required_states + else: + field_states['required'] = True + res[name]['states'] = encoder.encode(field_states) res[name]['string'] = account.name res[name]['relation'] = cls.__name__ res[name]['domain'] = PYSONEncoder().encode([