details: https://code.tryton.org/tryton/commit/91152da49e71
branch: default
user: Sergi Almacellas Abellana <[email protected]>
date: Mon Aug 17 23:31:29 2026 +0200
description:
Restrict updating party required of account with moves
Closes #14710
diffstat:
modules/account/account.py | 20 ++++++++++++++++++++
modules/account/message.xml | 3 +++
2 files changed, 23 insertions(+), 0 deletions(-)
diffs (43 lines):
diff -r bb0582a117bd -r 91152da49e71 modules/account/account.py
--- a/modules/account/account.py Tue Aug 11 12:02:33 2026 +0200
+++ b/modules/account/account.py Mon Aug 17 23:31:29 2026 +0200
@@ -1422,6 +1422,26 @@
}),
]
+ @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 -r bb0582a117bd -r 91152da49e71 modules/account/message.xml
--- a/modules/account/message.xml Tue Aug 11 12:02:33 2026 +0200
+++ b/modules/account/message.xml Mon Aug 17 23:31:29 2026 +0200
@@ -110,6 +110,9 @@
<record model="ir.message" id="msg_account_no_type_lines">
<field name="text">You cannot remove type of account "%(account)s"
because it has move lines.</field>
</record>
+ <record model="ir.message" id="msg_account_party_required_with_moves">
+ <field name="text">You cannot change the "Party Required" field of
account "%(account)s" because it contains lines.</field>
+ </record>
<record model="ir.message" id="msg_deferral_unique">
<field name="text">Deferral must be unique by account and fiscal
year.</field>