diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index a0ffbde9..f5bbd9ff 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -642,9 +642,18 @@ class TradeForm(NewActionForm): def validate(self, extra_validators=None): is_valid = super().validate(extra_validators) - if not self.confirm and not self.code: + if not self.confirm.data and not self.code.data: self.code.errors = ["If you don't want confirm, you need a code"] is_valid = False - return is_valid + if self.confirm.data and not (self.receiver.data or self.supplier.data): + errors = ["If you want confirm, you need a email"] + if not self.receiver.data: + self.receiver.errors = errors + if not self.supplier.data: + self.supplier.errors = errors + + is_valid = False + + return is_valid