From b848e619541e288c49222ce47197465cfd0a0d7f Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 19 Apr 2022 13:00:00 +0530 Subject: [PATCH] fix: Skip unpublished Variants with published templates in shopping cart quote validation --- erpnext/selling/doctype/quotation/quotation.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index de2a9baf5c..22371f763c 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -55,8 +55,20 @@ class Quotation(SellingController): return for item in self.items: - if not frappe.db.exists("Website Item", {"item_code": item.item_code}): - frappe.throw(_("Item {0} must be a website item for Shopping Cart quotations").format(item.item_code)) + has_web_item = frappe.db.exists("Website Item", {"item_code": item.item_code}) + + # If variant is unpublished but template is published: valid + template = frappe.get_cached_value("Item", item.item_code, "variant_of") + if template and not has_web_item: + has_web_item = frappe.db.exists("Website Item", {"item_code": template}) + + if not has_web_item: + frappe.throw( + _( + "Row #{0}: Item {1} must have a Website Item for Shopping Cart Quotations" + ).format(item.idx, frappe.bold(item.item_code)), + title=_("Unpublished Item") + ) def has_sales_order(self): return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1})