Pārlūkot izejas kodu

Check if child has parent not only on ID

master
Viggo de Vries 1 gadu atpakaļ
vecāks
revīzija
9afb182d57
1 mainītis faili ar 4 papildinājumiem un 2 dzēšanām
  1. 4
    2
      src/oscar/apps/catalogue/abstract_models.py

+ 4
- 2
src/oscar/apps/catalogue/abstract_models.py Parādīt failu

@@ -572,9 +572,11 @@ class AbstractProduct(models.Model):
572 572
         """
573 573
         Validates a child product
574 574
         """
575
-        if not self.parent_id:
575
+        has_parent = self.parent or self.parent_id
576
+
577
+        if not has_parent:
576 578
             raise ValidationError(_("A child product needs a parent."))
577
-        if self.parent_id and not self.parent.is_parent:
579
+        if has_parent and not self.parent.is_parent:
578 580
             raise ValidationError(
579 581
                 _("You can only assign child products to parent products.")
580 582
             )

Notiek ielāde…
Atcelt
Saglabāt