From 90daf2e88bfd894bfa1182ea09ed92fc6174d0c6 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 17 Aug 2026 23:31:29 +0200 Subject: [PATCH] Restrict updating party required of account with moves Closes #14710 --- modules/account/account.py | 20 ++++++++++++++++++++ modules/account/message.xml | 3 +++ 2 files changed, 23 insertions(+) diff --git a/modules/account/account.py b/modules/account/account.py index 324dcaff97..623e8453a5 100644 --- a/modules/account/account.py +++ b/modules/account/account.py @@ -1422,6 +1422,26 @@ class Account( }), ] + @classmethod + def check_modification(cls, mode, accounts, values=None, external=False): + pool = Pool() + MoveLine = pool.get('account.move.line') + super().check_modification( + mode, accounts, values=values, external=external) + # Only external to allow update from template + if mode == 'write' and external and 'party_required' in values: + if to_check := [ + a.id for a in accounts + if a.party_required != values['party_required']]: + if lines := MoveLine.search([ + ('account', 'in', to_check), + ], + limit=1, order=[]): + line, = lines + raise AccessError(gettext( + 'account.msg_account_party_required_with_moves', + account=line.account.rec_name)) + class AccountParty(ActivePeriodMixin, ModelSQL): __name__ = 'account.account.party' diff --git a/modules/account/message.xml b/modules/account/message.xml index 67427e9538..fcb7b0dc3e 100644 --- a/modules/account/message.xml +++ b/modules/account/message.xml @@ -110,6 +110,9 @@ this repository contains the full copyright notices and license terms. --> You cannot remove type of account "%(account)s" because it has move lines. + + You cannot change the "Party Required" field of account "%(account)s" because it contains lines. + Deferral must be unique by account and fiscal year.