fix: performance issue related to stock entry (#39301)

This commit is contained in:
rohitwaghchaure 2024-01-10 22:01:40 +05:30 committed by GitHub
parent f057dc6867
commit c67b0a3a64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -173,7 +173,7 @@ frappe.ui.form.on('Production Plan', {
method: "set_status", method: "set_status",
freeze: true, freeze: true,
doc: frm.doc, doc: frm.doc,
args: {close : close}, args: {close : close, update_bin: true},
callback: function() { callback: function() {
frm.reload_doc(); frm.reload_doc();
} }

View File

@ -579,7 +579,7 @@ class ProductionPlan(Document):
frappe.delete_doc("Work Order", d.name) frappe.delete_doc("Work Order", d.name)
@frappe.whitelist() @frappe.whitelist()
def set_status(self, close=None): def set_status(self, close=None, update_bin=False):
self.status = {0: "Draft", 1: "Submitted", 2: "Cancelled"}.get(self.docstatus) self.status = {0: "Draft", 1: "Submitted", 2: "Cancelled"}.get(self.docstatus)
if close: if close:
@ -599,7 +599,7 @@ class ProductionPlan(Document):
if close is not None: if close is not None:
self.db_set("status", self.status) self.db_set("status", self.status)
if self.docstatus == 1 and self.status != "Completed": if update_bin and self.docstatus == 1 and self.status != "Completed":
self.update_bin_qty() self.update_bin_qty()
def update_ordered_status(self): def update_ordered_status(self):

View File

@ -1486,14 +1486,14 @@ class TestProductionPlan(FrappeTestCase):
before_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan")) before_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))
pln.reload() pln.reload()
pln.set_status(close=True) pln.set_status(close=True, update_bin=True)
bin_name = get_or_make_bin(rm_item, rm_warehouse) bin_name = get_or_make_bin(rm_item, rm_warehouse)
after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan")) after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))
self.assertAlmostEqual(after_qty, before_qty - 10) self.assertAlmostEqual(after_qty, before_qty - 10)
pln.reload() pln.reload()
pln.set_status(close=False) pln.set_status(close=False, update_bin=True)
bin_name = get_or_make_bin(rm_item, rm_warehouse) bin_name = get_or_make_bin(rm_item, rm_warehouse)
after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan")) after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))