From d06b7049c7d4b8538c3d3bb1f6d4b57d6e74bb43 Mon Sep 17 00:00:00 2001 From: Maxwell Morais Date: Tue, 12 Dec 2017 07:16:16 -0200 Subject: [PATCH] Allow manufacturing order from SO with Packed Items that contains BOM's (#11947) --- .../doctype/production_order/production_order.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index d45fbde154..91d7eb6728 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -53,10 +53,13 @@ class ProductionOrder(Document): if self.sales_order: so = frappe.db.sql(""" select so.name, so_item.delivery_date, so.project - from `tabSales Order` so, `tabSales Order Item` so_item - where so.name=%s and so.name=so_item.parent - and so.docstatus = 1 and so_item.item_code=%s - """, (self.sales_order, self.production_item), as_dict=1) + from `tabSales Order` so + inner join `tabSales Order Item` so_item on so_item.parent = so.name + left join `tabProduct Bundle Item` pk_item on so_item.item_code = pk_item.parent + where so.name=%s and so.docstatus = 1 and ( + so_item.item_code=%s or + pk_item.item_code=%s ) + """, (self.sales_order, self.production_item, self.production_item), as_dict=1) if len(so): if not self.expected_delivery_date: