From 54183ea8183d7ff242c87f8a3c052a1bbf478b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 22 Jul 2026 12:28:03 +0200 Subject: [PATCH] Make statement lines readonly when origins are filled Closes #14965 --- modules/account_statement/statement.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/account_statement/statement.py b/modules/account_statement/statement.py index c3d1e3d352..7e3315ab5b 100644 --- a/modules/account_statement/statement.py +++ b/modules/account_statement/statement.py @@ -104,7 +104,10 @@ class Statement(Workflow, ModelSQL, ModelView, ChatMixin): states=_number_states) lines = fields.One2Many('account.statement.line', 'statement', 'Lines', states={ - 'readonly': (Eval('state') != 'draft') | ~Eval('journal'), + 'readonly': ( + (Eval('state') != 'draft') + | ~Eval('journal') + | Eval('origins', [])), }) origins = fields.One2Many('account.statement.origin', 'statement', "Origins", states={ @@ -253,11 +256,15 @@ class Statement(Workflow, ModelSQL, ModelView, ChatMixin): origin.lines = lines self.origins = origins - @fields.depends('lines') + @fields.depends('lines', 'origins') def on_change_lines(self): pool = Pool() Line = pool.get('account.statement.line') + if self.origins: + # let origin manage the pending amounts + return + invoices = {l.invoice for l in self.lines if l.invoice} invoice_id2amount_to_pay = {} for invoice in invoices: