changeset d71cf9bbd73d in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=d71cf9bbd73d
description:
        Ignore invalid intervals to compute next call of cron

        issue9842
        review333571002
diffstat:

 trytond/ir/cron.py |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 8dbf8a5a0424 -r d71cf9bbd73d trytond/ir/cron.py
--- a/trytond/ir/cron.py        Thu Jan 07 10:52:08 2021 +0100
+++ b/trytond/ir/cron.py        Fri Jan 08 22:52:03 2021 +0100
@@ -99,10 +99,24 @@
             + 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

Reply via email to