changeset 33c9ef88e247 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=33c9ef88e247
description:
Enforce statement coherence between children and parent of account type
issue11502
review445081003
diffstat:
account.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diffs (31 lines):
diff -r 4d1fcd864036 -r 33c9ef88e247 account.py
--- a/account.py Tue May 31 23:46:14 2022 +0200
+++ b/account.py Tue May 31 23:54:18 2022 +0200
@@ -236,6 +236,15 @@
},
domain=[
('company', '=', Eval('company')),
+ ['OR',
+ If(Eval('statement') == 'off-balance',
+ ('statement', '=', 'off-balance'),
+ If(Eval('statement') == 'balance',
+ ('statement', '=', 'balance'),
+ ('statement', '!=', 'off-balance')),
+ ),
+ ('statement', '=', None),
+ ],
])
childs = fields.One2Many('account.account.type', 'parent', 'Children',
domain=[
@@ -275,6 +284,11 @@
def default_company(cls):
return Transaction().context.get('company')
+ @fields.depends('parent', '_parent_parent.statement')
+ def on_change_parent(self):
+ if self.parent:
+ self.statement = self.parent.statement
+
def get_currency(self, name):
return self.company.currency.id