perf: duplicate queries while checking prevdoc (#35746)

These values can't change durning DB transaction AFAIK
This commit is contained in:
Ankush Menat 2023-06-16 18:25:58 +05:30 committed by GitHub
parent 29da1db516
commit 6086d1a99d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1001,10 +1001,16 @@ class SalesInvoice(SellingController):
def check_prev_docstatus(self):
for d in self.get("items"):
if d.sales_order and frappe.db.get_value("Sales Order", d.sales_order, "docstatus") != 1:
if (
d.sales_order
and frappe.db.get_value("Sales Order", d.sales_order, "docstatus", cache=True) != 1
):
frappe.throw(_("Sales Order {0} is not submitted").format(d.sales_order))
if d.delivery_note and frappe.db.get_value("Delivery Note", d.delivery_note, "docstatus") != 1:
if (
d.delivery_note
and frappe.db.get_value("Delivery Note", d.delivery_note, "docstatus", cache=True) != 1
):
throw(_("Delivery Note {0} is not submitted").format(d.delivery_note))
def make_gl_entries(self, gl_entries=None, from_repost=False):