From cbd2cc3da5a3ebd8e2f1b5c8eea49a97441f97a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 8 Jan 2021 22:52:03 +0100 Subject: [PATCH] Ignore invalid intervals to compute next call of cron issue9842 review333571002 --- trytond/ir/cron.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/trytond/ir/cron.py b/trytond/ir/cron.py index ed44da11e3..cb49869bdd 100644 --- a/trytond/ir/cron.py +++ b/trytond/ir/cron.py @@ -99,10 +99,24 @@ class Cron(DeactivableMixin, ModelSQL, ModelView): + relativedelta( microsecond=0, second=0, - minute=self.minute, - hour=self.hour, - day=self.day, - weekday=int(self.weekday.index) if self.weekday else None)) + minute=( + self.minute + if self.interval_type != 'minutes' + else None), + hour=( + self.hour + if self.interval_type not in {'minutes', 'hours'} + else None), + day=( + self.day + if self.interval_type not in { + 'minutes', 'hours', 'days', 'weeks'} + else None), + weekday=( + int(self.weekday.index) + if self.weekday + and self.interval_type not in {'minutes', 'hours', 'days'} + else None))) @dualmethod @ModelView.button