refactor(sales_order): replace SQL with ORM in check_nextdoc_docstatus (#55204)

This commit is contained in:
Loic Oberle
2026-05-23 08:04:18 +02:00
committed by GitHub
parent f1c2d2e21d
commit e27b88d789

View File

@@ -577,13 +577,12 @@ class SalesOrder(SellingController):
check_credit_limit(self.customer, self.company) check_credit_limit(self.customer, self.company)
def check_nextdoc_docstatus(self): def check_nextdoc_docstatus(self):
linked_invoices = frappe.db.sql_list( linked_invoices = frappe.get_all(
"""select distinct t1.name "Sales Invoice Item",
from `tabSales Invoice` t1,`tabSales Invoice Item` t2 filters={"sales_order": self.name, "docstatus": 0},
where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus = 0""", pluck="parent",
self.name, distinct=True,
) )
if linked_invoices: if linked_invoices:
linked_invoices = [get_link_to_form("Sales Invoice", si) for si in linked_invoices] linked_invoices = [get_link_to_form("Sales Invoice", si) for si in linked_invoices]
frappe.throw( frappe.throw(