Procházet zdrojové kódy

Check if child has parent not only on ID

master
Viggo de Vries před 1 rokem
rodič
revize
9afb182d57
1 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 4
    2
      src/oscar/apps/catalogue/abstract_models.py

+ 4
- 2
src/oscar/apps/catalogue/abstract_models.py Zobrazit soubor

@@ -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
             )

Načítá se…
Zrušit
Uložit