Closes #17577: Reference ModelState when determining whether an object is being created

This commit is contained in:
Jeremy Stretch
2024-09-23 17:04:18 -04:00
parent 6b219a279b
commit b46a89640f
8 changed files with 13 additions and 13 deletions

View File

@@ -164,7 +164,7 @@ class Cable(PrimaryModel):
if self.length is not None and not self.length_unit:
raise ValidationError(_("Must specify a unit when setting a cable length"))
if self.pk is None and (not self.a_terminations or not self.b_terminations):
if self._state.adding and (not self.a_terminations or not self.b_terminations):
raise ValidationError(_("Must define A and B terminations when creating a new cable."))
if self._terminations_modified: