mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-21 08:11:36 +02:00
fix: unable to update TransactionRuleAction
This commit is contained in:
@@ -102,13 +102,21 @@ class TransactionRuleActionForm(forms.ModelForm):
|
||||
field = cleaned_data.get("field")
|
||||
|
||||
if field and self.rule:
|
||||
if TransactionRuleAction.objects.filter(
|
||||
# Create a queryset that excludes the current instance
|
||||
existing_action = TransactionRuleAction.objects.filter(
|
||||
rule=self.rule, field=field
|
||||
).exists():
|
||||
)
|
||||
|
||||
if self.instance.pk:
|
||||
existing_action = existing_action.exclude(pk=self.instance.pk)
|
||||
|
||||
if existing_action.exists():
|
||||
raise ValidationError(
|
||||
_("A value for this field already exists in the rule.")
|
||||
)
|
||||
|
||||
return cleaned_data
|
||||
|
||||
def save(self, commit=True):
|
||||
instance = super().save(commit=False)
|
||||
instance.rule = self.rule
|
||||
|
||||
Reference in New Issue
Block a user