From 66ce484804444abb717cee36b3214ed943fcfbd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 16 Dec 2021 22:42:53 +0100 Subject: [PATCH] Compute the periods for type amount the same way as general ledger issue11039 review376171002 --- account.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/account.py b/account.py index cfcb8c299b..03402c387f 100644 --- a/account.py +++ b/account.py @@ -293,6 +293,7 @@ class Type( pool = Pool() Account = pool.get('account.account') GeneralLedger = pool.get('account.general_ledger.account') + context = Transaction().context res = {} for type_ in types: @@ -305,10 +306,13 @@ class Type( for type_ in childs: type_sum[type_.id] = Decimal('0.0') - 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))) + 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 with Transaction().set_context(periods=period_ids): accounts = Account.search([