From 29549bf1dee8c5ccaa18377338b0135cfa4d9916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 2 Apr 2026 17:57:12 +0200 Subject: [PATCH] Use party with origin's company in the context to retrieve accounts when applying statement rule Closes #14740 (grafted from d6e797ed25c68b052cefc5ccde35995f40028a3b) --HG-- branch : 7.0 --- modules/account_statement_rule/account.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/account_statement_rule/account.py b/modules/account_statement_rule/account.py index 25ed887165..14e81ef15c 100644 --- a/modules/account_statement_rule/account.py +++ b/modules/account_statement_rule/account.py @@ -317,6 +317,7 @@ class StatementRuleLine(sequence_ordered(), ModelSQL, ModelView): def get_line(self, origin, keywords, **context): pool = Pool() Line = pool.get('account.statement.line') + Party = pool.get('party.party') context.setdefault('functions', {})['Decimal'] = Decimal context.setdefault('names', {}).update(keywords) @@ -343,7 +344,10 @@ class StatementRuleLine(sequence_ordered(), ModelSQL, ModelView): if related_to_account: account = related_to_account elif party: - with Transaction().set_context(date=origin.date): + with Transaction().set_context( + date=origin.date, + company=origin.company.id): + party = Party(party.id) if amount > Decimal(0): account = party.account_receivable_used else: