Support date range context for account type amount

issue10346
review346041008
This commit is contained in:
Cédric Krier
2022-09-11 15:15:12 +02:00
parent 9f9d86415c
commit 95e4652e7a
2 changed files with 7 additions and 3 deletions
+1
View File
@@ -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
+6 -3
View File
@@ -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]),
])