浏览代码

Check if child has parent not only on ID

master
Viggo de Vries 1年前
父节点
当前提交
9afb182d57
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4
    2
      src/oscar/apps/catalogue/abstract_models.py

+ 4
- 2
src/oscar/apps/catalogue/abstract_models.py 查看文件

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

正在加载...
取消
保存