API: fix tax rules create default handling (#6490)

* API: fix tax rules create default handling

* fix flake8
This commit is contained in:
Richard Schreiber
2026-08-25 09:39:21 +02:00
committed by GitHub
parent dbd971cc22
commit d7aae65777
2 changed files with 22 additions and 13 deletions
+6 -2
View File
@@ -702,8 +702,12 @@ class TaxRuleSerializer(CountryFieldMixin, I18nAwareModelSerializer):
return super().save(**kwargs)
def validate_default(self, value):
if not value and self.instance.default:
raise ValidationError("You can't remove the default property, instead set it on another tax rule.")
if not value:
if self.instance:
if self.instance.default:
raise ValidationError("You can't remove the default property, instead set it on another tax rule.")
elif not self.context["event"].tax_rules.exists():
raise ValidationError("You can't remove the default property as there is only one tax rule.")
return value