changeset 1b3d9d7a758f in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=1b3d9d7a758f
description:
Computes GeneralLedger timespan on either dates or period
issue10249
review351991002
diffstat:
account.py | 49 ++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 42 insertions(+), 7 deletions(-)
diffs (97 lines):
diff -r 9f4fabb78e30 -r 1b3d9d7a758f account.py
--- a/account.py Mon Oct 11 23:21:55 2021 +0200
+++ b/account.py Tue Oct 12 11:29:34 2021 +0200
@@ -1059,7 +1059,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]
@@ -1680,8 +1680,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):
@@ -1797,27 +1805,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 include posted moves.")
journal = fields.Many2One(
@@ -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"