From fa887ce39f11d7a97148b77bd205010fd4d38d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Bernardi?= Date: Thu, 19 Feb 2026 13:07:37 +0100 Subject: [PATCH] Use the same context for the account getter and searcher of general ledger Closes #14590 (grafted from 488439bb54ccc54f1173d9a33af418a24a0c71fd) --HG-- branch : 6.0 --- modules/account/account.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/account/account.py b/modules/account/account.py index 9eb2ac86b0..27946c54c8 100644 --- a/modules/account/account.py +++ b/modules/account/account.py @@ -1786,9 +1786,7 @@ class _GeneralLedgerAccount(ActivePeriodMixin, ModelSQL, ModelView): return None, None @classmethod - def get_account(cls, records, name): - Account = cls._get_account() - + def _account_context(cls, name): period_ids, from_date, to_date = None, None, None context = Transaction().context if context.get('start_period') or context.get('end_period'): @@ -1798,10 +1796,17 @@ class _GeneralLedgerAccount(ActivePeriodMixin, ModelSQL, ModelView): else: if name.startswith('start_'): period_ids = [] + return { + 'periods': period_ids, + 'from_date': from_date, + 'to_date': to_date, + } - with Transaction().set_context( - periods=period_ids, - from_date=from_date, to_date=to_date): + @classmethod + def get_account(cls, records, name): + Account = cls._get_account() + + with Transaction().set_context(cls._account_context(name)): accounts = Account.browse(records) fname = name for test in ['start_', 'end_']: @@ -1814,8 +1819,7 @@ class _GeneralLedgerAccount(ActivePeriodMixin, ModelSQL, ModelView): def search_account(cls, name, domain): Account = cls._get_account() - period_ids = cls.get_period_ids(name) - with Transaction().set_context(periods=period_ids): + with Transaction().set_context(cls._account_context(name)): accounts = Account.search([], order=[]) _, operator_, operand = domain