From 58ff651c6d1aca04aef1addb4b7d438ba34a687f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 19 Jun 2014 14:43:54 +0530 Subject: [PATCH 1/2] fixes to bom.js --- erpnext/manufacturing/doctype/bom/bom.js | 41 ++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index 1cee6b9103..ef4f399bdc 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt // On REFRESH +frappe.provide("erpnext.bom"); cur_frm.cscript.refresh = function(doc,dt,dn){ cur_frm.toggle_enable("item", doc.__islocal); @@ -10,7 +11,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn){ } cur_frm.cscript.with_operations(doc); - set_operation_no(doc); + erpnext.bom.set_operation_no(doc); } cur_frm.cscript.update_cost = function() { @@ -30,10 +31,10 @@ cur_frm.cscript.with_operations = function(doc) { cur_frm.cscript.operation_no = function(doc, cdt, cdn) { var child = locals[cdt][cdn]; - if(child.parentfield=="bom_operations") set_operation_no(doc); + if(child.parentfield=="bom_operations") erpnext.bom.set_operation_no(doc); } -var set_operation_no = function(doc) { +erpnext.bom.set_operation_no = function(doc) { var op_table = doc.bom_operations || []; var operations = []; @@ -53,7 +54,7 @@ var set_operation_no = function(doc) { } cur_frm.fields_dict["bom_operations"].grid.on_row_delete = function(cdt, cdn){ - set_operation_no(doc); + erpnext.bom.set_operation_no(doc); } cur_frm.add_fetch("item", "description", "description"); @@ -64,15 +65,15 @@ cur_frm.cscript.workstation = function(doc,dt,dn) { frappe.model.with_doc("Workstation", d.workstation, function(i, r) { d.hour_rate = r.docs[0].hour_rate; refresh_field("hour_rate", dn, "bom_operations"); - calculate_op_cost(doc); - calculate_total(doc); + erpnext.bom.calculate_op_cost(doc); + erpnext.bom.calculate_total(doc); }); } cur_frm.cscript.hour_rate = function(doc, dt, dn) { - calculate_op_cost(doc); - calculate_total(doc); + erpnext.bom.calculate_op_cost(doc); + erpnext.bom.calculate_total(doc); } @@ -106,8 +107,8 @@ var get_bom_material_detail= function(doc, cdt, cdn) { $.extend(d, r.message); refresh_field("bom_materials"); doc = locals[doc.doctype][doc.name]; - calculate_rm_cost(doc); - calculate_total(doc); + erpnext.bom.calculate_rm_cost(doc); + erpnext.bom.calculate_total(doc); }, freeze: true }); @@ -116,8 +117,8 @@ var get_bom_material_detail= function(doc, cdt, cdn) { cur_frm.cscript.qty = function(doc, cdt, cdn) { - calculate_rm_cost(doc); - calculate_total(doc); + erpnext.bom.calculate_rm_cost(doc); + erpnext.bom.calculate_total(doc); } cur_frm.cscript.rate = function(doc, cdt, cdn) { @@ -126,12 +127,12 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) { msgprint(__("You can not change rate if BOM mentioned agianst any item")); get_bom_material_detail(doc, cdt, cdn); } else { - calculate_rm_cost(doc); - calculate_total(doc); + erpnext.bom.calculate_rm_cost(doc); + erpnext.bom.calculate_total(doc); } } -var calculate_op_cost = function(doc) { +erpnext.bom.calculate_op_cost = function(doc) { var op = doc.bom_operations || []; total_op_cost = 0; for(var i=0;i Date: Mon, 23 Jun 2014 12:20:12 +0530 Subject: [PATCH 2/2] fix end of life query for item --- erpnext/controllers/queries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 789e7a331a..0f1d5f6dab 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -141,7 +141,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters): concat(substr(tabItem.description, 1, 40), "..."), description) as decription from tabItem where tabItem.docstatus < 2 - and (tabItem.end_of_life is null or tabItem.end_of_life > %(today)s) + and (tabItem.end_of_life > %(today)s or ifnull(tabItem.end_of_life, '0000-00-00')='0000-00-00') and (tabItem.`{key}` LIKE %(txt)s or tabItem.item_name LIKE %(txt)s) {fcond} {mcond}