From 845980c01022509e01ba0d7db75ea48d91eca2d3 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 25 Jun 2015 13:13:53 +0530 Subject: [PATCH] Added Feature - Update FG based on Material Transfer For Manufacturing --- .../manufacturing_settings.json | 11 ++++++- erpnext/public/js/financial_statements.js | 6 ++++ .../stock/doctype/stock_entry/stock_entry.py | 31 ++++++++++++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json index eb770a8609..dff04a4389 100644 --- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json +++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json @@ -41,6 +41,15 @@ "permlevel": 0, "precision": "" }, + { + "default": "BOM", + "fieldname": "update_fg_based_on", + "fieldtype": "Select", + "label": "Update FG Based On", + "options": "BOM\nMaterial Transfer for Manufacture", + "permlevel": 0, + "precision": "" + }, { "fieldname": "column_break_3", "fieldtype": "Column Break", @@ -79,7 +88,7 @@ "in_dialog": 0, "is_submittable": 0, "issingle": 1, - "istable": 0, + "istable": 0, "modified": "2015-07-23 08:12:33.889753", "modified_by": "Administrator", "module": "Manufacturing", diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js index 9a1a05afaa..2ce7a1fb3a 100644 --- a/erpnext/public/js/financial_statements.js +++ b/erpnext/public/js/financial_statements.js @@ -25,6 +25,12 @@ erpnext.financial_statements = { "options": "Yearly\nHalf-yearly\nQuarterly\nMonthly", "default": "Yearly", "reqd": 1 + }, + { + "fieldname": "accumulated_value", + "label": __("Accumulated Value"), + "fieldtype": "Check", + "depends_on": "eval:accumulated_value= 'Yearly'" } ], "formatter": function(row, cell, value, columnDef, dataContext, default_formatter) { diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 01129bfe47..a9b950587a 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -551,6 +551,12 @@ class StockEntry(StockController): if self.to_warehouse and self.pro_doc: for item in item_dict.values(): item["to_warehouse"] = self.pro_doc.wip_warehouse + self.add_to_stock_entry_detail(item_dict) + + elif self.production_order and self.purpose == "Manufacture" and \ + frappe.db.get_single_value("Manufacturing Settings", "update_fg_based_on")== "Material Transfer for Manufacture": + self.get_transfered_raw_materials() + else: if not self.fg_completed_qty: frappe.throw(_("Manufacturing Quantity is mandatory")) @@ -561,9 +567,7 @@ class StockEntry(StockController): item["from_warehouse"] = self.pro_doc.wip_warehouse item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else "" - - # add raw materials to Stock Entry Detail table - self.add_to_stock_entry_detail(item_dict) + self.add_to_stock_entry_detail(item_dict) # add finished goods item if self.purpose in ("Manufacture", "Repack"): @@ -604,8 +608,27 @@ class StockEntry(StockController): for item in item_dict.values(): item.from_warehouse = self.from_warehouse or item.default_warehouse - return item_dict + + def get_transfered_raw_materials(self): + items_dict = frappe.db.sql("""select item_name, item_code, sum(qty) as qty, to_warehouse, from_warehouse, + description, stock_uom, expense_account, cost_center from `tabStock Entry` se,`tabStock Entry Detail` sed + where se.name = sed.parent and se.docstatus=1 and se.purpose='Material Transfer for Manufacture' and + se.production_order= %s and se.to_warehouse= %s group by sed.item_code;""", + (self.production_order, self.from_warehouse), as_dict=1) + for item in items_dict: + self.add_to_stock_entry_detail({ + item.item_code: { + "to_warehouse": item.to_warehouse, + "from_warehouse": item.from_warehouse, + "qty": item.qty, + "item_name": item.item_name, + "description": item.description, + "stock_uom": item.stock_uom, + "expense_account": item.expense_account, + "cost_center": item.buying_cost_center, + } + }) def get_pending_raw_materials(self): """