mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
refactor(sales_order): Replace SQL with ORM in validate_sales_mntc_qu… (#55201)
This commit is contained in:
@@ -397,16 +397,20 @@ class SalesOrder(SellingController):
|
|||||||
return frappe.db.exists("Item", {"name": ["in", bundle_items], "is_stock_item": 1}) is not None
|
return frappe.db.exists("Item", {"name": ["in", bundle_items], "is_stock_item": 1}) is not None
|
||||||
|
|
||||||
def validate_sales_mntc_quotation(self):
|
def validate_sales_mntc_quotation(self):
|
||||||
|
quotation_names = [d.prevdoc_docname for d in self.get("items") if d.prevdoc_docname]
|
||||||
|
|
||||||
|
if not quotation_names:
|
||||||
|
return
|
||||||
|
|
||||||
|
valid_quotations = frappe.get_all(
|
||||||
|
"Quotation",
|
||||||
|
filters={"name": ["in", quotation_names], "order_type": self.order_type},
|
||||||
|
pluck="name",
|
||||||
|
)
|
||||||
|
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
if d.prevdoc_docname:
|
if d.prevdoc_docname and d.prevdoc_docname not in valid_quotations:
|
||||||
res = frappe.db.sql(
|
frappe.msgprint(_("Quotation {0} not of type {1}").format(d.prevdoc_docname, self.order_type))
|
||||||
"select name from `tabQuotation` where name=%s and order_type = %s",
|
|
||||||
(d.prevdoc_docname, self.order_type),
|
|
||||||
)
|
|
||||||
if not res:
|
|
||||||
frappe.msgprint(
|
|
||||||
_("Quotation {0} not of type {1}").format(d.prevdoc_docname, self.order_type)
|
|
||||||
)
|
|
||||||
|
|
||||||
def validate_delivery_date(self):
|
def validate_delivery_date(self):
|
||||||
if self.order_type == "Sales" and not self.skip_delivery_note:
|
if self.order_type == "Sales" and not self.skip_delivery_note:
|
||||||
|
|||||||
Reference in New Issue
Block a user