Skip to content

Commit

Permalink
fix: performance issue related to stock entry (#39301)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure authored Jan 10, 2024
1 parent f057dc6 commit c67b0a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ frappe.ui.form.on('Production Plan', {
method: "set_status",
freeze: true,
doc: frm.doc,
args: {close : close},
args: {close : close, update_bin: true},
callback: function() {
frm.reload_doc();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def delete_draft_work_order(self):
frappe.delete_doc("Work Order", d.name)

@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)

if close:
Expand All @@ -599,7 +599,7 @@ def set_status(self, close=None):
if close is not None:
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()

def update_ordered_status(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1486,14 +1486,14 @@ def test_unreserve_qty_on_closing_of_pp(self):
before_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))

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)
after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))
self.assertAlmostEqual(after_qty, before_qty - 10)

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)
after_qty = flt(frappe.db.get_value("Bin", bin_name, "reserved_qty_for_production_plan"))
Expand Down

0 comments on commit c67b0a3

Please sign in to comment.