Use party with origin's company in the context to retrieve accounts when applying statement rule

Closes #14740
This commit is contained in:
Cédric Krier
2026-04-02 17:57:12 +02:00
parent 9b255e2f63
commit 280d432ae4
+5 -1
View File
@@ -319,6 +319,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)
@@ -345,7 +346,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: