From 5414725fd62798314ba49502d4c78fa5caa9ddd7 Mon Sep 17 00:00:00 2001 From: RobertSchouten Date: Tue, 13 Sep 2016 08:27:51 +0800 Subject: [PATCH] PPT material request non-stock items --- .../production_planning_tool.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py index fd28b547a98..cfa6cdc01ac 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -307,7 +307,7 @@ class ProductionPlanningTool(Document): self.get_raw_materials(bom_dict) return self.get_csv() - def get_raw_materials(self, bom_dict): + def get_raw_materials(self, bom_dict,non_stock_item=False): """ Get raw materials considering sub-assembly items { "item_code": [qty_required, description, stock_uom, min_order_qty] @@ -326,7 +326,7 @@ class ProductionPlanningTool(Document): from `tabBOM Explosion Item` fb, `tabBOM` bom, `tabItem` item where bom.name = fb.parent and item.name = fb.item_code and (item.is_sub_contracted_item = 0 or ifnull(item.default_bom, "")="") - and item.is_stock_item = 1 + """ + ("and item.is_stock_item = 1","")[non_stock_item] + """ and fb.docstatus<2 and bom.name=%(bom)s group by fb.item_code, fb.stock_uom""", {"bom":bom}, as_dict=1): bom_wise_item_details.setdefault(d.item_code, d) @@ -334,7 +334,7 @@ class ProductionPlanningTool(Document): # Get all raw materials considering SA items as raw materials, # so no childs of SA items bom_wise_item_details = self.get_subitems(bom_wise_item_details, bom,1, \ - self.use_multi_level_bom,self.only_raw_materials, self.include_subcontracted) + self.use_multi_level_bom,self.only_raw_materials, self.include_subcontracted,non_stock_item) for item, item_details in bom_wise_item_details.items(): for so_qty in so_wise_qty: @@ -343,14 +343,14 @@ class ProductionPlanningTool(Document): self.make_items_dict(item_list) - def get_subitems(self,bom_wise_item_details, bom, parent_qty, include_sublevel, only_raw, supply_subs): + def get_subitems(self,bom_wise_item_details, bom, parent_qty, include_sublevel, only_raw, supply_subs,non_stock_item=False): for d in frappe.db.sql("""select bom_item.item_code, default_material_request_type, ifnull(%(parent_qty)s * sum(bom_item.qty/ifnull(bom.quantity, 1)), 0) as qty, item.is_sub_contracted_item as is_sub_contracted, item.default_bom as default_bom from `tabBOM Item` bom_item, `tabBOM` bom, tabItem item where bom.name = bom_item.parent and bom.name = %(bom)s and bom_item.docstatus < 2 and bom_item.item_code = item.name - and item.is_stock_item = 1 + """ + ("and item.is_stock_item = 1","")[non_stock_item] + """ group by bom_item.item_code""", {"bom": bom, "parent_qty": parent_qty}, as_dict=1): if (d.default_material_request_type == "Purchase" and not (d.is_sub_contracted \ and only_raw and include_sublevel)) or (d.default_material_request_type == \ @@ -399,7 +399,7 @@ class ProductionPlanningTool(Document): frappe.throw(_("Please enter Warehouse for which Material Request will be raised")) bom_dict = self.get_so_wise_planned_qty() - self.get_raw_materials(bom_dict) + self.get_raw_materials(bom_dict,self.create_material_requests_non_stock_request) if self.item_dict: self.create_material_request()