diff --git a/contracts/models.py b/contracts/models.py index ca97769da3939c7dbd8d9236a14aa17c13ac5270..dc3b9265d52664481ce59aa3fbfba5d562c4790a 100644 --- a/contracts/models.py +++ b/contracts/models.py @@ -657,6 +657,17 @@ class Contract(NameStrMixin, models.Model): } ) + if ( + self.valid_start_date + and self.valid_end_date + and self.valid_start_date > self.valid_end_date + ): + raise ValidationError( + { + "valid_end_date": "Konec platnosti nemůže být definován dříve, než začátek." + } + ) + if self.cost_amount is None and self.cost_unit: # 0 is falsy, but a value raise ValidationError( {"cost_unit": "Nemůže být definováno, pokud nejsou zadány náklady."}