From b7fc4b76e421a44f07cb30ea83de6c6632ed638e Mon Sep 17 00:00:00 2001 From: RobertSchouten Date: Fri, 9 Sep 2016 11:02:33 +0800 Subject: [PATCH 1/5] stock entries from production_order dont fetch serial number of project stock entries from production_order dont fetch serial number of project --- .../manufacturing/doctype/production_order/production_order.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 2bf32048aa..d598ee24b5 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -478,10 +478,12 @@ def make_stock_entry(production_order_id, purpose, qty=None): if production_order.source_warehouse: stock_entry.from_warehouse = production_order.source_warehouse stock_entry.to_warehouse = production_order.wip_warehouse + stock_entry.project = production_order.project else: stock_entry.from_warehouse = production_order.wip_warehouse stock_entry.to_warehouse = production_order.fg_warehouse additional_costs = get_additional_costs(production_order, fg_qty=stock_entry.fg_completed_qty) + stock_entry.project = frappe.db.get_value("Stock Entry",{"production_order": production_order_id,"purpose": "Material Transfer for Manufacture"}, "project") stock_entry.set("additional_costs", additional_costs) stock_entry.get_items() From 2efe20bd9a4feb8bcf70fc1176e9c212f870d67e Mon Sep 17 00:00:00 2001 From: RobertSchouten Date: Fri, 9 Sep 2016 11:05:22 +0800 Subject: [PATCH 2/5] stock entries from production_order dont fetch serial number of project --- .../doctype/production_planning_tool/production_planning_tool.py | 1 + 1 file changed, 1 insertion(+) 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 acb3ab8f1b..ce849de798 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -249,6 +249,7 @@ class ProductionPlanningTool(Document): "wip_warehouse" : "", "fg_warehouse" : d.warehouse, "status" : "Draft", + "project" : frappe.db.get_value("Sales Order",d.sales_order,"Project") } """ Club similar BOM and item for processing in case of Sales Orders """ From b64fc33be1360c2c792841b31429bf6992b60588 Mon Sep 17 00:00:00 2001 From: RobertSchouten Date: Fri, 9 Sep 2016 11:08:39 +0800 Subject: [PATCH 3/5] stock entries from production_order dont fetch serial number of project --- erpnext/stock/doctype/stock_entry/stock_entry.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index e35f3d2965..f31901512d 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -232,6 +232,18 @@ class StockEntry(StockController): frappe.bold(d.transfer_qty)), NegativeStockError, title=_('Insufficient Stock')) + def set_serial_nos(self,production_order_id): + + previous_se = frappe.db.get_value("Stock Entry",{"production_order": production_order_id, + "purpose": "Material Transfer for Manufacture"}, "name") + + for d in self.get('items'): + previous_serial_no = frappe.db.get_value("Stock Entry Detail",{"parent": previous_se, + "item_code": d.item_code}, "serial_no") + + if previous_serial_no: + d.serial_no = previous_serial_no + def get_stock_and_rate(self): self.set_transfer_qty() self.set_actual_qty() @@ -551,6 +563,9 @@ class StockEntry(StockController): item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else "" self.add_to_stock_entry_detail(item_dict) + # fetch the serial_no of the first stock entry for the second stock entry + if self.production_order and self.purpose == "Manufacture": + self.set_serial_nos(self.production_order) # add finished goods item if self.purpose in ("Manufacture", "Repack"): From d7b95267b398036cedd7d9691503162a9283dc98 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 12 Sep 2016 18:33:17 +0530 Subject: [PATCH 4/5] Update production_planning_tool.py --- .../production_planning_tool/production_planning_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ce849de798..fd28b547a9 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -249,7 +249,7 @@ class ProductionPlanningTool(Document): "wip_warehouse" : "", "fg_warehouse" : d.warehouse, "status" : "Draft", - "project" : frappe.db.get_value("Sales Order",d.sales_order,"Project") + "project" : frappe.db.get_value("Sales Order", d.sales_order, "project") } """ Club similar BOM and item for processing in case of Sales Orders """ From 6c08f5caf91382a63de8890300aff116ad6e19bd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 12 Sep 2016 18:34:46 +0530 Subject: [PATCH 5/5] Update stock_entry.py --- erpnext/stock/doctype/stock_entry/stock_entry.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index f31901512d..e7e3eb1541 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -232,17 +232,16 @@ class StockEntry(StockController): frappe.bold(d.transfer_qty)), NegativeStockError, title=_('Insufficient Stock')) - def set_serial_nos(self,production_order_id): - - previous_se = frappe.db.get_value("Stock Entry",{"production_order": production_order_id, + def set_serial_nos(self, production_order): + previous_se = frappe.db.get_value("Stock Entry", {"production_order": production_order, "purpose": "Material Transfer for Manufacture"}, "name") for d in self.get('items'): - previous_serial_no = frappe.db.get_value("Stock Entry Detail",{"parent": previous_se, + transferred_serial_no = frappe.db.get_value("Stock Entry Detail",{"parent": previous_se, "item_code": d.item_code}, "serial_no") - if previous_serial_no: - d.serial_no = previous_serial_no + if transferred_serial_no: + d.serial_no = transferred_serial_no def get_stock_and_rate(self): self.set_transfer_qty()