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.