Missing constraints to several ir.cron fields
ir.cron uses relativedelta and fills it from several fields of the model. Relativedelta itself seems to have no constraints on the range of values used, but it crashes when you try to increase the value of a datetime with a relativedelta(hour=24), with the following backtrace:
Traceback (most recent call last): File "/tryton/trytond/trytond/ir/cron.py", line 134, in run cron.next_call = cron.compute_next_call(now) File "/tryton/trytond/trytond/ir/cron.py", line 103, in compute_next_call weekday=int(self.weekday.index) if self.weekday else None)) File "/usr/local/lib/python3.7/dist-packages/dateutil/relativedelta.py", line 405, in radd return self.add(other) File "/usr/local/lib/python3.7/dist-packages/dateutil/relativedelta.py", line 387, in add ret = (other.replace(**repl) ValueError: hour must be in 0..23
So we must ensure we follow relativedelta constraints which are:
- minute must be between 0 and 59
- hour must be between 0 and 23
- day does not seem to have a constraint but using a day above 31 will cause the last day of the month to be used
I see two possibilities:
- We add a domain on minute and hour fields
- We don't add any constraints but use minute=self.minute % 60 and hour=self.hour % 24 when setting relativedelta.
Opinions?