From 4c089b585208f235656955a2a0287b189f02ae2d Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sun, 7 Mar 2021 11:25:03 +0530 Subject: [PATCH] minor fixes --- .../manufacturing/doctype/work_order/work_order.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index ca530bbadd..3d64ad4318 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -528,6 +528,10 @@ class WorkOrder(Document): if not reset_only_qty: self.required_items = [] + operation = None + if self.get('operations') and len(self.operations) == 1: + operation = self.operations[0].operation + if self.bom_no and self.qty: item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=self.qty, fetch_exploded = self.use_multi_level_bom) @@ -536,6 +540,9 @@ class WorkOrder(Document): for d in self.get("required_items"): if item_dict.get(d.item_code): d.required_qty = item_dict.get(d.item_code).get("qty") + + if not d.operation: + d.operation = operation else: # Attribute a big number (999) to idx for sorting putpose in case idx is NULL # For instance in BOM Explosion Item child table, the items coming from sub assembly items @@ -543,7 +550,7 @@ class WorkOrder(Document): self.append('required_items', { 'rate': item.rate, 'amount': item.amount, - 'operation': item.operation, + 'operation': item.operation or operation, 'item_code': item.item_code, 'item_name': item.item_name, 'description': item.description, @@ -879,7 +886,7 @@ def create_job_card(work_order, row, qty=0, enable_capacity_planning=False, auto doc.schedule_time_logs(row) doc.insert() - frappe.msgprint(_("Job card {0} created").format(get_link_to_form("Job Card", doc.name))) + frappe.msgprint(_("Job card {0} created").format(get_link_to_form("Job Card", doc.name)), alert=True) return doc