changeset c73204d8efed in modules/account:6.0
details: https://hg.tryton.org/modules/account?cmd=changeset&node=c73204d8efed
description:
Use the same periods to open account as in query_get
issue11034
review391231002
(grafted from aeee5ff5c50a0dbe40e8237c41059845df618dee)
diffstat:
move.py | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
diffs (50 lines):
diff -r 1e6f6acf5c01 -r c73204d8efed move.py
--- a/move.py Fri Dec 03 21:57:55 2021 +0100
+++ b/move.py Thu Dec 16 22:35:46 2021 +0100
@@ -1066,7 +1066,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:
@@ -1517,17 +1519,28 @@
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'):
+ company_id = self.record.company.id if self.record else -1
+ date = context.get('date')
+ fiscalyear = context.get('fiscalyear')
+ if date:
+ fiscalyears = FiscalYear.search([
+ ('start_date', '<=', date),
+ ('end_date', '>=', date),
+ ('company', '=', company_id),
+ ],
+ order=[('start_date', 'DESC')],
+ limit=1)
+ elif fiscalyear:
+ fiscalyears = [FiscalYear(fiscalyear)]
+ else:
fiscalyears = FiscalYear.search([
('state', '=', 'open'),
- ('company', '=',
- self.record.company.id if self.record else None),
+ ('company', '=', company_id),
])
- else:
- fiscalyears = [FiscalYear(Transaction().context['fiscalyear'])]
-
periods = [p for f in fiscalyears for p in f.periods]
action['pyson_domain'] = [