details:   https://code.tryton.org/tryton/commit/05134f4fdd0a
branch:    7.6
user:      Cédric Krier <[email protected]>
date:      Thu Apr 02 17:57:12 2026 +0200
description:
        Use party with origin's company in the context to retrieve accounts 
when applying statement rule

        Closes #14740
        (grafted from d6e797ed25c68b052cefc5ccde35995f40028a3b)
diffstat:

 modules/account_statement_rule/account.py |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (23 lines):

diff -r 8714930676b1 -r 05134f4fdd0a modules/account_statement_rule/account.py
--- a/modules/account_statement_rule/account.py Thu Apr 02 17:25:24 2026 +0200
+++ b/modules/account_statement_rule/account.py Thu Apr 02 17:57:12 2026 +0200
@@ -316,6 +316,7 @@
     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)
 
@@ -342,7 +343,10 @@
             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:

Reply via email to