From 125d413b69356234d53442addf9dfc26a3f7bb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 20 Jan 2025 20:01:05 +0100 Subject: [PATCH] Make company of statement readonly once there is a line The content of the lines depends on the company of the statement, so the user should not change it once he started to fill the lines. --- modules/account_statement/statement.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/account_statement/statement.py b/modules/account_statement/statement.py index 5e394a7f95..c54926d4f4 100644 --- a/modules/account_statement/statement.py +++ b/modules/account_statement/statement.py @@ -71,7 +71,10 @@ class Statement(Workflow, ModelSQL, ModelView): name = fields.Char('Name', required=True) company = fields.Many2One( - 'company.company', "Company", required=True, states=_states) + 'company.company', "Company", required=True, + states={ + 'readonly': (Eval('state') != 'draft') | Eval('lines', [0]), + }) journal = fields.Many2One( 'account.statement.journal', "Journal", required=True, domain=[