forbid past dates for product actions

This commit is contained in:
imperosol
2025-09-29 15:03:34 +02:00
parent 09d9529f0d
commit e9da0d8c4f
2 changed files with 13 additions and 2 deletions

View File

@@ -1385,3 +1385,13 @@ class ScheduledProductAction(PeriodicTask):
def full_clean(self, *args, **kwargs):
self.one_off = True # A product action should occur one time only
return super().full_clean(*args, **kwargs)
def clean_clocked(self):
if not self.clocked:
raise ValidationError(_("Product actions must declare a clocked schedule."))
def validate_unique(self, exclude):
# The checks done in PeriodicTask.validate_unique aren't
# adapted in the case of scheduled product action,
# so we skip it and execute directly Model.validate_unique
return super(PeriodicTask, self).validate_unique(exclude=exclude)