Compute the periods for type amount the same way as general ledger

issue11039
review376171002
(grafted from 491d585d8424f3cdbf05f4e793446e808e5a47dc)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2021-12-16 22:42:53 +01:00
1 parent 423ca12a81
commit be209868e3
1 file changed
+8 -4
+8 -4
View File
@@ -294,6 +294,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:
@@ -306,10 +307,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([