From 2c069a418a366734c3347387499fd97a211e5b2c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 3 Dec 2015 11:10:23 +0530 Subject: [PATCH] [minor] allow stock entry for manufacture without production order --- .../stock/doctype/stock_entry/stock_entry.js | 18 +++++++++--------- .../stock/doctype/stock_entry/stock_entry.py | 6 ++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index e9fc134152..3965417d23 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -148,11 +148,11 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ $.each(["from_bom", "bom_no", "fg_completed_qty", "use_multi_level_bom"], function(i, field) { me.frm.set_value(field, r.message[field]); }) - + if (me.frm.doc.purpose == "Material Transfer for Manufacture" && !me.frm.doc.to_warehouse) me.frm.set_value("to_warehouse", r.message["wip_warehouse"]); - - + + if (me.frm.doc.purpose == "Manufacture") { if(r.message["additional_costs"].length) { $.each(r.message["additional_costs"], function(i, row) { @@ -160,7 +160,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }) refresh_field("additional_costs"); } - + if (!me.frm.doc.from_warehouse) me.frm.set_value("from_warehouse", r.message["wip_warehouse"]); if (!me.frm.doc.to_warehouse) me.frm.set_value("to_warehouse", r.message["fg_warehouse"]); } @@ -171,7 +171,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, toggle_enable_bom: function() { - this.frm.toggle_enable("bom_no", !in_list(["Manufacture", "Material Transfer for Manufacture"], this.frm.doc.purpose)); + this.frm.toggle_enable("bom_no", !!!this.frm.doc.production_order); }, add_excise_button: function() { @@ -252,11 +252,11 @@ cur_frm.cscript.toggle_related_fields = function(doc) { if(doc.purpose == "Material Receipt") { cur_frm.set_value("from_bom", 0); } - + // Addition costs based on purpose - cur_frm.toggle_display(["additional_costs", "total_additional_costs", "additional_costs_section"], + cur_frm.toggle_display(["additional_costs", "total_additional_costs", "additional_costs_section"], doc.purpose!='Material Issue'); - + cur_frm.fields_dict["items"].grid.set_column_disp("additional_cost", doc.purpose!='Material Issue'); } @@ -405,4 +405,4 @@ cur_frm.cscript.company = function(doc, cdt, cdn) { cur_frm.cscript.posting_date = function(doc, cdt, cdn){ erpnext.get_fiscal_year(doc.company, doc.posting_date); -} \ No newline at end of file +} diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 79cd8de9df..9702972604 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -170,10 +170,8 @@ class StockEntry(StockController): def validate_production_order(self): if self.purpose in ("Manufacture", "Material Transfer for Manufacture"): # check if production order is entered - if not self.production_order: - frappe.throw(_("Production order number is mandatory for stock entry purpose manufacture")) - # check for double entry - if self.purpose=="Manufacture": + + if self.purpose=="Manufacture" and self.production_order: if not self.fg_completed_qty: frappe.throw(_("For Quantity (Manufactured Qty) is mandatory")) self.check_if_operations_completed()