From 95e4652e7a3328f696e7eaa6d9f8ba678e90bbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 11 Sep 2022 15:15:12 +0200 Subject: [PATCH] Support date range context for account type amount issue10346 review346041008 --- CHANGELOG | 1 + account.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3432911216..1057fb8e41 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Support date range context for account type amount * Use context model for chart of accounts and taxes Version 6.4.0 - 2022-05-02 diff --git a/account.py b/account.py index d563ff8cbf..3c83a76fb3 100644 --- a/account.py +++ b/account.py @@ -310,15 +310,18 @@ class Type( for type_ in childs: type_sum[type_.id] = Decimal('0.0') + period_ids = from_date = to_date = None if context.get('start_period') or context.get('end_period'): start_period_ids = GeneralLedger.get_period_ids('start_%s' % name) end_period_ids = GeneralLedger.get_period_ids('end_%s' % name) period_ids = list( set(end_period_ids).difference(set(start_period_ids))) - else: - period_ids = None + elif context.get('from_date') or context.get('to_date'): + from_date, _ = GeneralLedger.get_dates('start_%s' % name) + _, to_date = GeneralLedger.get_dates('end_%s' % name) - with Transaction().set_context(periods=period_ids): + with Transaction().set_context( + periods=period_ids, from_date=from_date, to_date=to_date): accounts = Account.search([ ('type', 'in', [t.id for t in childs]), ])