changeset 64ae8b042f2d in modules/account:default details: https://hg.tryton.org/modules/account?cmd=changeset;node=64ae8b042f2d description: Use today as default date when inside the period
issue8389 review259541002 diffstat: CHANGELOG | 2 ++ move.py | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diffs (59 lines): diff -r d010b58cc69a -r 64ae8b042f2d CHANGELOG --- a/CHANGELOG Mon Jun 03 15:59:23 2019 +0200 +++ b/CHANGELOG Thu Jun 06 19:23:36 2019 +0200 @@ -1,3 +1,5 @@ +* Use today as default date when inside the period + Version 5.2.0 - 2019-05-06 * Bug fixes (see mercurial logs for details) * Add group lines wizard diff -r d010b58cc69a -r 64ae8b042f2d move.py --- a/move.py Mon Jun 03 15:59:23 2019 +0200 +++ b/move.py Thu Jun 06 19:23:36 2019 +0200 @@ -156,20 +156,29 @@ pool = Pool() Period = pool.get('account.period') Date = pool.get('ir.date') + today = Date.today() period_id = cls.default_period() if period_id: period = Period(period_id) - return period.start_date - return Date.today() + if today < period.start_date or today > period.end_date: + return period.start_date + return today @fields.depends('period', 'journal', 'date') def on_change_with_date(self): - Line = Pool().get('account.move.line') + pool = Pool() + Line = pool.get('account.move.line') + Date = pool.get('ir.date') + today = Date.today() date = self.date if date: if self.period and not ( self.period.start_date <= date <= self.period.end_date): - date = self.period.start_date + if (today >= self.period.start_date + and today <= self.period.end_date): + date = today + else: + date = self.period.start_date return date lines = Line.search([ ('journal', '=', self.journal), @@ -178,7 +187,11 @@ if lines: date = lines[0].date elif self.period: - date = self.period.start_date + if (today >= self.period.start_date + and today <= self.period.end_date): + date = today + else: + date = self.period.start_date return date @classmethod