changeset 457a43244a31 in modules/account:5.8
details: https://hg.tryton.org/modules/account?cmd=changeset&node=457a43244a31
description:
Computes GeneralLedger timespan on either dates or period
issue10249
review351991002
(grafted from 1b3d9d7a758f7db21e171103b17f27442583cea8)
diffstat:
account.py | 49 ++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 42 insertions(+), 7 deletions(-)
diffs (97 lines):
diff -r 9b2ae6b16182 -r 457a43244a31 account.py
--- a/account.py Thu Jul 01 21:47:58 2021 +0200
+++ b/account.py Tue Oct 12 11:29:34 2021 +0200
@@ -1030,7 +1030,7 @@
values[name][account.id] += getattr(deferral, name)
else:
with Transaction().set_context(fiscalyear=fiscalyear.id,
- date=None, periods=None):
+ date=None, periods=None, from_date=None, to_date=None):
previous_result = func(accounts, names)
for name in names:
vals = values[name]
@@ -1688,8 +1688,16 @@
def get_account(cls, records, name):
Account = cls._get_account()
- period_ids = cls.get_period_ids(name)
- from_date, to_date = cls.get_dates(name)
+ period_ids, from_date, to_date = None, None, None
+ context_keys = Transaction().context.keys()
+ if context_keys & {'start_period', 'end_period'}:
+ period_ids = cls.get_period_ids(name)
+ elif context_keys & {'from_date', 'end_date'}:
+ from_date, to_date = cls.get_dates(name)
+ else:
+ if name.startswith('start_'):
+ period_ids = []
+
with Transaction().set_context(
periods=period_ids,
from_date=from_date, to_date=to_date):
@@ -1808,27 +1816,42 @@
domain=[
('fiscalyear', '=', Eval('fiscalyear')),
('start_date', '<=', (Eval('end_period'), 'start_date')),
- ], depends=['fiscalyear', 'end_period'])
+ ],
+ states={
+ 'invisible': Eval('from_date', False) | Eval('to_date', False),
+ },
+ depends=['fiscalyear', 'end_period', 'from_date', 'to_date'])
end_period = fields.Many2One('account.period', 'End Period',
domain=[
('fiscalyear', '=', Eval('fiscalyear')),
('start_date', '>=', (Eval('start_period'), 'start_date'))
],
- depends=['fiscalyear', 'start_period'])
+ states={
+ 'invisible': Eval('from_date', False) | Eval('to_date', False),
+ },
+ depends=['fiscalyear', 'start_period', 'from_date', 'to_date'])
from_date = fields.Date("From Date",
domain=[
If(Eval('to_date') & Eval('from_date'),
('from_date', '<=', Eval('to_date')),
()),
],
- depends=['to_date'])
+ states={
+ 'invisible': (Eval('start_period', 'False')
+ | Eval('end_period', False)),
+ },
+ depends=['to_date', 'start_period', 'end_period'])
to_date = fields.Date("To Date",
domain=[
If(Eval('from_date') & Eval('to_date'),
('to_date', '>=', Eval('from_date')),
()),
],
- depends=['from_date'])
+ states={
+ 'invisible': (Eval('start_period', 'False')
+ | Eval('end_period', False)),
+ },
+ depends=['from_date', 'start_period', 'end_period'])
company = fields.Many2One('company.company', 'Company', required=True)
posted = fields.Boolean('Posted Move', help="Only included posted moves.")
@@ -1874,6 +1897,18 @@
and self.end_period.fiscalyear != self.fiscalyear):
self.end_period = None
+ def on_change_start_period(self):
+ self.from_date = self.to_date = None
+
+ def on_change_end_period(self):
+ self.from_date = self.to_date = None
+
+ def on_change_from_date(self):
+ self.start_period = self.end_period = None
+
+ def on_change_to_date(self):
+ self.start_period = self.end_period = None
+
class GeneralLedgerAccountParty(_GeneralLedgerAccount):
"General Ledger Account Party"