diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js index 3cdfb20742e8e27d743f233096376f6100dc80a7..0d99a923a0091b2158cc8bef72550d39af8c5ccf 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.js +++ b/erpnext/manufacturing/doctype/work_order/work_order.js @@ -439,6 +439,10 @@ frappe.ui.form.on("Work Order", { erpnext.work_order .show_prompt_for_qty_input(frm, "Disassemble") .then((data) => { + if (flt(data.qty) <= 0) { + frappe.msgprint(__("Disassemble Qty cannot be less than or equal to 0.")); + return; + } return frappe.xcall("erpnext.manufacturing.doctype.work_order.work_order.make_stock_entry", { work_order_id: frm.doc.name, purpose: "Disassemble", diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 9408afc2d87113d850ba154c1e11bde1d6d6621b..282c9646973d3f3b4bd7ee97c556318dee8365a5 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -2349,7 +2349,7 @@ def make_stock_entry( stock_entry.set_stock_entry_type() stock_entry.is_additional_transfer_entry = is_additional_transfer_entry - stock_entry.get_items(qty, work_order.production_item) + stock_entry.get_items() if purpose != "Disassemble": stock_entry.set_serial_no_batch_for_finished_good() diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index c199838bf74078dd2ccb63fe5b93855f01df306c..ca5a7d5e86fbd15cafacb9be8714e5e4b3ea58ae 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -2159,7 +2159,7 @@ class StockEntry(StockController, SubcontractingInwardController): }, ) - def get_items_for_disassembly(self, disassemble_qty, production_item): + def get_items_for_disassembly(self): """Get items for Disassembly Order""" if not self.work_order: @@ -2172,7 +2172,7 @@ class StockEntry(StockController, SubcontractingInwardController): items_dict = get_bom_items_as_dict( self.bom_no, self.company, - disassemble_qty, + self.fg_completed_qty, fetch_exploded=self.use_multi_level_bom, fetch_qty_in_stock_uom=False, ) @@ -2189,8 +2189,8 @@ class StockEntry(StockController, SubcontractingInwardController): child_row.qty = bom_items.get("qty", child_row.qty) child_row.amount = bom_items.get("amount", child_row.amount) - if row.item_code == production_item: - child_row.qty = disassemble_qty + if row.is_finished_item: + child_row.qty = self.fg_completed_qty child_row.s_warehouse = (self.from_warehouse or s_warehouse) if row.is_finished_item else "" child_row.t_warehouse = row.s_warehouse @@ -2226,12 +2226,12 @@ class StockEntry(StockController, SubcontractingInwardController): ) @frappe.whitelist() - def get_items(self, qty=None, production_item=None): + def get_items(self): self.set("items", []) self.validate_work_order() - if self.purpose == "Disassemble" and qty is not None: - return self.get_items_for_disassembly(qty, production_item) + if self.purpose == "Disassemble": + return self.get_items_for_disassembly() if not self.posting_date or not self.posting_time: frappe.throw(_("Posting date and posting time is mandatory"))