From e0cc8f03c6d53333787e66b7a2ae87253f9292f8 Mon Sep 17 00:00:00 2001 From: Bernat Brunet Date: Fri, 2 Jun 2023 10:15:11 +0200 Subject: [PATCH] I add extra depends on the three account_bank_statements modules to ensure that when the cancel/delete order is coming from there is allowed even if the account move is posted. Task: #159291 --- account.py | 18 +++++++++++------- tryton.cfg | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/account.py b/account.py index 2e657ae..bf5fe36 100644 --- a/account.py +++ b/account.py @@ -8,6 +8,7 @@ from trytond.pyson import Eval, Bool from trytond.i18n import gettext from trytond.exceptions import UserError from trytond.model.exceptions import AccessError +from trytond.transaction import Transaction __all__ = ['Configuration', 'Account', 'Move', 'MoveLine'] @@ -257,13 +258,16 @@ class MoveLine(metaclass=PoolMeta): 'state': 'draft', }) - for line in lines: - if line.move.state == 'posted': - raise AccessError(gettext( - 'account.msg_modify_line_posted_move', - line=line.rec_name, - move=line.move.rec_name, - )) + from_statement = Transaction().context.get( + 'from_account_bank_statement_line', False) + if not from_statement: + for line in lines: + if line.move.state == 'posted': + raise AccessError(gettext( + 'account.msg_modify_line_posted_move', + line=line.rec_name, + move=line.move.rec_name, + )) super(MoveLine, cls).delete(lines) @dualmethod diff --git a/tryton.cfg b/tryton.cfg index 4cff56e..b3d41cd 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -8,6 +8,9 @@ extras_depend: account_invoice analytic_invoice analytic_account_move + account_bank_statement + account_bank_statement_counterpart + account_bank_statement_account xml: account.xml analytic.xml