From 9d3f0405b7de4c63e7dcc426d188a4813db0ff94 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 22 Mar 2013 12:02:48 +0530 Subject: [PATCH 1/2] fixes in packing slip --- stock/doctype/packing_slip/packing_slip.js | 6 ++- stock/doctype/packing_slip/packing_slip.py | 46 +++++++++------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/stock/doctype/packing_slip/packing_slip.js b/stock/doctype/packing_slip/packing_slip.js index 706c6f5141..e9396d9edc 100644 --- a/stock/doctype/packing_slip/packing_slip.js +++ b/stock/doctype/packing_slip/packing_slip.js @@ -19,7 +19,8 @@ cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) { } -cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) { +cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = + function(doc, cdt, cdn) { var query = 'SELECT name, item_name, description FROM `tabItem` WHERE name IN ( \ SELECT item_code FROM `tabDelivery Note Item` dnd \ WHERE parent="' + doc.delivery_note + '" AND IFNULL(qty, 0) > IFNULL(packed_qty, 0)) AND %(key)s LIKE "%s" LIMIT 50'; @@ -34,9 +35,10 @@ cur_frm.add_fetch("item_code", "net_weight", "net_weight"); cur_frm.add_fetch("item_code", "weight_uom", "weight_uom"); cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { + console.log(make_doclist(cdt, cdn)); if(doc.delivery_note && doc.__islocal) { var ps_detail = getchildren('Packing Slip Item', doc.name, 'item_details'); - if(!(flt(ps_detail[0].net_weight) && cstr(ps_detail[0].weight_uom))) { + if(!(flt(ps_detail.net_weight) && cstr(ps_detail.weight_uom))) { cur_frm.cscript.update_item_details(doc); } } diff --git a/stock/doctype/packing_slip/packing_slip.py b/stock/doctype/packing_slip/packing_slip.py index 5f4fda05a1..72682b2de3 100644 --- a/stock/doctype/packing_slip/packing_slip.py +++ b/stock/doctype/packing_slip/packing_slip.py @@ -40,15 +40,12 @@ class DocType: """ Validates if delivery note has status as submitted """ - res = webnotes.conn.sql("""\ - SELECT docstatus FROM `tabDelivery Note` - WHERE name=%(delivery_note)s - """, self.doc.fields) + res = webnotes.conn.sql("""SELECT docstatus FROM `tabDelivery Note` + WHERE name=%(delivery_note)s""", self.doc.fields) if not(res and res[0][0]==0): webnotes.msgprint("""Invalid Delivery Note. Delivery Note should exist - and should be in draft state. Please rectify and try again.""", - raise_exception=1) + and should be in draft state. Please rectify and try again.""", raise_exception=1) def validate_case_nos(self): @@ -65,11 +62,10 @@ class DocType: raise_exception=1) - res = webnotes.conn.sql("""\ - SELECT name FROM `tabPacking Slip` + res = webnotes.conn.sql("""SELECT name FROM `tabPacking Slip` WHERE delivery_note = %(delivery_note)s AND docstatus = 1 AND (from_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s - OR to_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s)\ + OR to_case_no BETWEEN %(from_case_no)s AND %(to_case_no)s) """, self.doc.fields) if res: @@ -133,10 +129,10 @@ class DocType: item['recommended_qty'] = (flt(item['qty']) - flt(item['packed_qty'])) / no_of_cases item['specified_qty'] = flt(ps_item_qty[item['item_code']]) - webnotes.msgprint("""\ + webnotes.msgprint(""" Invalid Quantity specified (%(specified_qty)s %(stock_uom)s). %(packed_qty)s out of %(qty)s %(stock_uom)s already packed for %(item_code)s. - Recommended quantity for %(item_code)s = %(recommended_qty)s \ + Recommended quantity for %(item_code)s = %(recommended_qty)s %(stock_uom)s""" % item, raise_exception=1) @@ -167,16 +163,15 @@ class DocType: for item in dn_details: new_packed_qty = flt(item['packed_qty']) if (new_packed_qty < 0) or (new_packed_qty > flt(item['qty'])): - webnotes.msgprint("Invalid new packed quantity for item %s. \ - Please try again or contact support@erpnext.com" % item['item_code'], raise_exception=1) + webnotes.msgprint("""Invalid new packed quantity for item %s. + Please try again or contact support@erpnext.com""" % + item['item_code'], raise_exception=1) - webnotes.conn.sql("""\ - UPDATE `tabDelivery Note Item` - SET packed_qty = %s - WHERE parent = %s AND item_code = %s""", + webnotes.conn.sql("""UPDATE `tabDelivery Note Item` + SET packed_qty = %s WHERE parent = %s AND item_code = %s""", (new_packed_qty, self.doc.delivery_note, item['item_code'])) - webnotes.conn.set_value("Delivery Note", self.doc.delivery_note, - "modified", now()) + + webnotes.conn.set_value("Delivery Note", self.doc.delivery_note, "modified", now()) def update_item_details(self): @@ -191,8 +186,7 @@ class DocType: def set_item_details(self, row): - res = webnotes.conn.sql("""\ - SELECT item_name, SUM(IFNULL(qty, 0)) as total_qty, + res = webnotes.conn.sql("""SELECT item_name, SUM(IFNULL(qty, 0)) as total_qty, IFNULL(packed_qty, 0) as packed_qty, stock_uom FROM `tabDelivery Note Item` WHERE parent=%s AND item_code=%s GROUP BY item_code""", @@ -203,10 +197,9 @@ class DocType: if not row.qty: row.qty = qty >= 0 and qty or 0 - res = webnotes.conn.sql("""\ - SELECT net_weight, weight_uom FROM `tabItem` - WHERE name=%s""", self.doc.item_code, as_dict=1) - + res = webnotes.conn.sql("""SELECT net_weight, weight_uom FROM `tabItem` + WHERE name=%s""", row.item_code, as_dict=1) + if res and len(res)>0: row.net_weight = res[0]["net_weight"] row.weight_uom = res[0]["weight_uom"] @@ -217,8 +210,7 @@ class DocType: Returns the next case no. for a new packing slip for a delivery note """ - recommended_case_no = webnotes.conn.sql("""\ - SELECT MAX(to_case_no) FROM `tabPacking Slip` + recommended_case_no = webnotes.conn.sql("""SELECT MAX(to_case_no) FROM `tabPacking Slip` WHERE delivery_note = %(delivery_note)s AND docstatus=1""", self.doc.fields) return cint(recommended_case_no[0][0]) + 1 \ No newline at end of file From 54e79995ee3eec585475784d19cf2e17a27c93ec Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 22 Mar 2013 12:35:11 +0530 Subject: [PATCH 2/2] fixes in trend analyzer --- accounts/search_criteria/trend_analyzer/trend_analyzer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/accounts/search_criteria/trend_analyzer/trend_analyzer.js b/accounts/search_criteria/trend_analyzer/trend_analyzer.js index 7f4b94b34b..59d948342a 100644 --- a/accounts/search_criteria/trend_analyzer/trend_analyzer.js +++ b/accounts/search_criteria/trend_analyzer/trend_analyzer.js @@ -16,6 +16,7 @@ report.customize_filters = function() { this.hide_all_filters(); + this.dt.set_no_limit(1); // hide transaction based on permissions var all_transactions = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice",