changeset 9a3f7878f6fd in modules/account:5.0
details: https://hg.tryton.org/modules/account?cmd=changeset&node=9a3f7878f6fd
description:
Use the same periods to open account as in query_get
issue11034
review391231002
(grafted from aeee5ff5c50a0dbe40e8237c41059845df618dee)
diffstat:
move.py | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diffs (45 lines):
diff -r b55d22f22eec -r 9a3f7878f6fd move.py
--- a/move.py Fri Nov 05 00:21:01 2021 +0100
+++ b/move.py Thu Dec 16 22:35:46 2021 +0100
@@ -958,7 +958,9 @@
('start_date', '<=', date),
('end_date', '>=', date),
('company', '=', company),
- ], limit=1)
+ ],
+ order=[('start_date', 'DESC')],
+ limit=1)
if fiscalyears:
fiscalyear_id = fiscalyears[0].id
else:
@@ -1376,15 +1378,25 @@
open_ = StateAction('account.act_move_line_form')
def do_open_(self, action):
- FiscalYear = Pool().get('account.fiscalyear')
+ pool = Pool()
+ FiscalYear = pool.get('account.fiscalyear')
+ context = Transaction().context
- if not Transaction().context.get('fiscalyear'):
+ date = context.get('date')
+ fiscalyear = context.get('fiscalyear')
+ if date:
+ fiscalyears = FiscalYear.search([
+ ('start_date', '<=', date),
+ ('end_date', '>=', date),
+ ],
+ order=[('start_date', 'DESC')],
+ limit=1)
+ elif fiscalyear:
+ fiscalyears = [FiscalYear(fiscalyear)]
+ else:
fiscalyears = FiscalYear.search([
('state', '=', 'open'),
])
- else:
- fiscalyears = [FiscalYear(Transaction().context['fiscalyear'])]
-
periods = [p for f in fiscalyears for p in f.periods]
action['pyson_domain'] = [