fix(currencies): don't error out if from_currency or to_currency isn't set

This commit is contained in:
Herculino Trotta
2025-01-26 20:52:47 -03:00
parent c88a6dcf3a
commit d7c072a35c
+2
View File
@@ -72,6 +72,8 @@ class ExchangeRate(models.Model):
def clean(self): def clean(self):
super().clean() super().clean()
# Check if the attributes exist before comparing them
if hasattr(self, "from_currency") and hasattr(self, "to_currency"):
if self.from_currency == self.to_currency: if self.from_currency == self.to_currency:
raise ValidationError( raise ValidationError(
{"to_currency": _("From and To currencies cannot be the same.")} {"to_currency": _("From and To currencies cannot be the same.")}