From a71ace0d74983f345298341d0cfc9870daa468db Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Feb 2013 16:30:53 +0530 Subject: [PATCH 01/20] fixed asynchronus issue in purchase cycle --- .../purchase_invoice/purchase_invoice.js | 25 ++++--- .../purchase_common/purchase_common.js | 15 ++--- .../doctype/purchase_order/purchase_order.js | 20 ++++-- .../supplier_quotation/supplier_quotation.js | 15 ++++- stock/doctype/item/item.txt | 65 +++---------------- .../purchase_receipt/purchase_receipt.js | 22 ++++--- 6 files changed, 70 insertions(+), 92 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index bfcf0a4bbd..b4fe62e3b6 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -33,6 +33,21 @@ erpnext.buying.PurchaseInvoiceController = erpnext.buying.BuyingController.exten } cur_frm.cscript.is_opening(doc); + }, + onload_post_render: function(doc, dt, dn) { + var me = this; + var callback1 = function(doc, dt, dn) { + var callback2 = function(doc, dt, dn) { + if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc, dt, dn); + } + me.update_item_details(doc, dt, dn, callback2); + } + + // TODO: improve this + if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name + && this.frm.doc.price_list_name) { + this.price_list_name(callback1); + } } }); @@ -46,16 +61,6 @@ cur_frm.cscript.onload = function(doc,dt,dn) { if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()}); } -cur_frm.cscript.onload_post_render = function(doc, dt, dn) { - var callback = function(doc, dt, dn) { - if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn); - } - - // defined in purchase_common.js - cur_frm.cscript.update_item_details(doc, dt, dn, callback); - -} - cur_frm.cscript.supplier = function(doc,dt,dn) { var callback = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname]; diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index b3f62d58b9..b8346d3893 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -51,15 +51,9 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ if(this.frm.fields_dict.currency) this.set_dynamic_labels(); - - // TODO: improve this - if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name - && this.frm.doc.price_list_name && this.frm.doc.price_list_currency) { - this.price_list_name(); - } }, - price_list_name: function() { + price_list_name: function(callback_fn) { this.frm.toggle_reqd(["price_list_currency", "plc_conversion_rate"], !!(this.frm.doc.price_list_name)); @@ -77,6 +71,8 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ callback: function(r) { if(!r.exc) { me.price_list_currency(); + if (callback_fn) callback_fn(me.frm.doc, me.frm.doc.doctype, + me.frm.doc.name); } } }); @@ -89,6 +85,7 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ item_code: function(doc, cdt, cdn) { var me = this; var item = locals[cdt][cdn]; + if(item.item_code) { this.frm.call({ method: "buying.utils.get_item_details", @@ -141,11 +138,11 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ price_list_currency: function() { this.set_dynamic_labels(); - + if(this.frm.doc.price_list_currency === this.get_company_currency()) this.frm.set_value("plc_conversion_rate", 1.0); else if(this.frm.doc.price_list_currency === this.frm.doc.currency) - this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate || 1.0); + this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate || 1.0); }, set_dynamic_labels: function(doc, dt, dn) { diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js index cf1db141c0..4bcd828899 100644 --- a/buying/doctype/purchase_order/purchase_order.js +++ b/buying/doctype/purchase_order/purchase_order.js @@ -40,12 +40,22 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( }, - onload_post_render: function(doc, dt, dn) { - var callback = function(doc, dt, dn) { - if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc); + onload_post_render: function(doc, dt, dn) { + var me = this; + var callback1 = function(doc, dt, dn) { + var callback2 = function(doc, dt, dn) { + if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc); + } + me.update_item_details(doc, dt, dn, callback2); + } + + // TODO: improve this + if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name + && this.frm.doc.price_list_name) { + this.price_list_name(callback1); } - this.update_item_details(doc, dt, dn, callback); } + }); var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm}); @@ -53,7 +63,7 @@ var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm}); // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new_cscript); -cur_frm.cscript.onload = function(doc, cdt, cdn) { +cur_frm.cscript.onload = function(doc, cdt, cdn) { // set missing values in parent doc set_missing_values(doc, { fiscal_year: sys_defaults.fiscal_year, diff --git a/buying/doctype/supplier_quotation/supplier_quotation.js b/buying/doctype/supplier_quotation/supplier_quotation.js index 6cb764ef08..36f9be8dc8 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/buying/doctype/supplier_quotation/supplier_quotation.js @@ -27,12 +27,25 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext refresh: function() { this._super(); - cur_frm.cscript.load_taxes(this.frm.doc); if (this.frm.doc.docstatus === 1) { cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order); } + }, + + onload_post_render: function(doc, dt, dn) { + var me = this; + var callback = function(doc, dt, dn) { + cur_frm.cscript.load_taxes(me.frm.doc); + } + + // TODO: improve this + if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name + && this.frm.doc.price_list_name) { + this.price_list_name(callback); + } } + }); var new_cscript = new erpnext.buying.SupplierQuotationController({frm: cur_frm}); diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index 6b1a60f580..1a48368ad2 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-20 13:26:14", + "creation": "2013-02-21 14:54:43", "docstatus": 0, - "modified": "2013-02-20 18:14:06", + "modified": "2013-02-28 10:43:02", "modified_by": "Administrator", "owner": "Administrator" }, @@ -28,13 +28,14 @@ "permlevel": 0 }, { - "amend": 0, "doctype": "DocPerm", "name": "__common__", "parent": "Item", "parentfield": "permissions", "parenttype": "DocType", + "permlevel": 0, "read": 1, + "report": 1, "submit": 0 }, { @@ -596,7 +597,6 @@ "label": "Price Lists and Rates" }, { - "depends_on": "eval:doc.is_sales_item==\"Yes\"", "description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.", "doctype": "DocField", "fieldname": "ref_rate_details", @@ -812,76 +812,27 @@ "fieldtype": "Text Editor", "label": "Website Description" }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "Material Manager", - "write": 0 - }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "Material Manager", - "write": 0 - }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "Material User", - "write": 0 - }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "Material User", - "write": 0 - }, { "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "report": 1, "role": "Material Master Manager", "write": 1 }, { + "amend": 0, "cancel": 0, "create": 0, "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "Material Master Manager", + "role": "Material Manager", "write": 0 }, { - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "role": "System Manager", - "write": 1 - }, - { + "amend": 0, "cancel": 0, "create": 0, "doctype": "DocPerm", - "permlevel": 1, - "report": 0, - "role": "System Manager", + "role": "Material User", "write": 0 } ] \ No newline at end of file diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index df2825b65b..c7d2e504f5 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -37,6 +37,18 @@ erpnext.buying.PurchaseReceiptController = erpnext.buying.BuyingController.exten if(wn.boot.control_panel.country == 'India') { unhide_field(['challan_no', 'challan_date']); } + }, + onload_post_render: function(doc, dt, dn) { + var me = this; + var callback = function(doc, dt, dn) { + me.update_item_details(doc, dt, dn, function(r,rt) { }); + } + + // TODO: improve this + if(this.frm.doc.__islocal && this.frm.fields_dict.price_list_name + && this.frm.doc.price_list_name) { + this.price_list_name(callback); + } } }); @@ -45,7 +57,6 @@ var new_cscript = new erpnext.buying.PurchaseReceiptController({frm: cur_frm}); // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new_cscript); -//========================== On Load ================================================================ cur_frm.cscript.onload = function(doc, cdt, cdn) { if(!doc.fiscal_year && doc.__islocal){ wn.model.set_default_values(doc);} if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date()); @@ -53,15 +64,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { if (!doc.status) doc.status = 'Draft'; } -cur_frm.cscript.onload_post_render = function(doc, dt, dn) { - var callback = function(doc, dt, dn) { - // defined in purchase_common.js - cur_frm.cscript.update_item_details(doc, dt, dn, function(r,rt) { }); - } - cur_frm.cscript.dynamic_label(doc, dt, dn, callback); -} - -//Supplier cur_frm.cscript.supplier = function(doc,dt,dn) { if (doc.supplier) { get_server_fields('get_default_supplier_address', From a8caa5edef727a7085303064492f42789e0697a1 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Feb 2013 16:45:37 +0530 Subject: [PATCH 02/20] patch to delete warehouses with docstatus = 2 --- patches/february_2013/p09_remove_cancelled_warehouses.py | 9 +++++++++ patches/patch_list.py | 1 + 2 files changed, 10 insertions(+) create mode 100644 patches/february_2013/p09_remove_cancelled_warehouses.py diff --git a/patches/february_2013/p09_remove_cancelled_warehouses.py b/patches/february_2013/p09_remove_cancelled_warehouses.py new file mode 100644 index 0000000000..05e569ab72 --- /dev/null +++ b/patches/february_2013/p09_remove_cancelled_warehouses.py @@ -0,0 +1,9 @@ +import webnotes + +def execute(): + for w in webnotes.conn.sql("""select name from `tabWarehouse` where docstatus=2"""): + try: + webnotes.delete_doc("Warehouse", w[0]) + except webnotes.ValidationError: + pass + \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 11608098c1..9e5d6f69af 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -200,4 +200,5 @@ patch_list = [ 'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Modern") # 2013-02-26', 'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Spartan") # 2013-02-26', "execute:(not webnotes.conn.exists('Role', 'Projects Manager')) and webnotes.doc({'doctype':'Role', 'role_name':'Projects Manager'}).insert()", + "patches.february_2013.p09_remove_cancelled_warehouses", ] \ No newline at end of file From 86dc8886488231d1871c2759477d601d6884431f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Feb 2013 17:09:08 +0530 Subject: [PATCH 03/20] datetime issue in stock balance repory --- stock/page/stock_balance/stock_balance.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js index dccf498a9e..9494f0dde6 100644 --- a/stock/page/stock_balance/stock_balance.js +++ b/stock/page/stock_balance/stock_balance.js @@ -102,8 +102,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({ for(var i=0, j=data.length; i Date: Thu, 28 Feb 2013 17:41:03 +0530 Subject: [PATCH 04/20] fix in subcontracted validation --- stock/doctype/purchase_receipt/purchase_receipt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 6772103759..88003ca682 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -293,7 +293,7 @@ class DocType(BuyingController): webnotes.msgprint(_("""Please enter whether Purchase Recipt is made for subcontracting or purchasing, in 'Is Subcontracted' field"""), raise_exception=1) - if self.doc.is_subcontracted and not self.doc.supplier_warehouse: + if self.doc.is_subcontracted=="Yes" and not self.doc.supplier_warehouse: webnotes.msgprint(_("Please Enter Supplier Warehouse for subcontracted Items"), raise_exception=1) From 15e7c186390a3097617dc6af7a08bb6c396e71d6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Feb 2013 18:10:19 +0530 Subject: [PATCH 05/20] fixes in price list currency --- buying/doctype/purchase_common/purchase_common.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index b8346d3893..7775426eaa 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -54,9 +54,6 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ }, price_list_name: function(callback_fn) { - this.frm.toggle_reqd(["price_list_currency", "plc_conversion_rate"], - !!(this.frm.doc.price_list_name)); - var me = this; if(this.frm.doc.price_list_name) { @@ -137,6 +134,9 @@ erpnext.buying.BuyingController = erpnext.utils.Controller.extend({ }, price_list_currency: function() { + this.frm.toggle_reqd("plc_conversion_rate", + !!(this.frm.doc.price_list_name && this.frm.doc.price_list_currency)); + this.set_dynamic_labels(); if(this.frm.doc.price_list_currency === this.get_company_currency()) From 380f555a8c4419293a848a7df1cbcf6228338251 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Feb 2013 18:41:49 +0530 Subject: [PATCH 06/20] fixes in price list currency --- setup/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/utils.py b/setup/utils.py index 1b61ea9201..1a86921692 100644 --- a/setup/utils.py +++ b/setup/utils.py @@ -40,7 +40,7 @@ def get_price_list_currency(args): if isinstance(args, basestring): args = json.loads(args) - result = webnotes.conn.sql("""select ref_currency from `tabItem Price` + result = webnotes.conn.sql("""select distinct ref_currency from `tabItem Price` where price_list_name=%s and `%s`=1""" % ("%s", args.get("use_for")), (args.get("price_list_name"),)) if result and len(result)==1: From b05185ba965cd1b3432054de01ba0784bdd7d5b0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Feb 2013 18:49:17 +0530 Subject: [PATCH 07/20] hide website fields function removed --- stock/doctype/item/item.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index 6c2c882645..5b32a34c80 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -22,13 +22,11 @@ cur_frm.cscript.refresh = function(doc) { if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) { var callback = function(r, rt) { - var enabled = (r.message == 'exists') ? false : true; + var enabled = (r.message == 'exists') ? false : true; cur_frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method'], enabled); } $c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback); } - - cur_frm.cscript.hide_website_fields(doc); } cur_frm.cscript.item_code = function(doc) { From 1bfec3a6c8a2da17423a382abfda32e41b62ebba Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Feb 2013 19:17:46 +0530 Subject: [PATCH 08/20] buying - update valuation rate when item row has item_code and quantity, else set valuation rate as 0 --- buying/utils.py | 2 +- controllers/buying_controller.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/buying/utils.py b/buying/utils.py index 9d125de24a..0431e642cb 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -53,7 +53,7 @@ def get_item_details(args): "qty": 0, "stock_uom": item.stock_uom, "uom": item.stock_uom, - "conversion_factor": 1, + "conversion_factor": 1.0, "warehouse": args.warehouse or item.default_warehouse, "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in item_wrapper.doclist.get({"parentfield": "item_tax"})))), diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index c49bf2a929..e5b8b07108 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -331,7 +331,9 @@ class BuyingController(AccountsController): # update valuation rate def update_valuation_rate(self, parentfield): for d in self.doclist.get({"parentfield": parentfield}): - if d.qty: + if d.item_code and d.qty: + # if no item code, which is sometimes the case in purchase invoice, + # then it is not possible to track valuation against it d.valuation_rate = (flt(d.purchase_rate or d.rate) + (flt(d.item_tax_amount) + flt(d.rm_supp_cost)) / flt(d.qty) ) / flt(d.conversion_factor) From a9afc254bc03d4cc0a3287733009e2b0449713a7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Mar 2013 10:41:41 +0530 Subject: [PATCH 09/20] fixes for conversion factor in old invoices --- controllers/buying_controller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index e5b8b07108..8b247ccd98 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -331,6 +331,9 @@ class BuyingController(AccountsController): # update valuation rate def update_valuation_rate(self, parentfield): for d in self.doclist.get({"parentfield": parentfield}): + d.conversion_factor = d.conversion_factor or webnotes.conn.get_value( + "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom}, + "conversion_factor") or 1 if d.item_code and d.qty: # if no item code, which is sometimes the case in purchase invoice, # then it is not possible to track valuation against it From 5657cd775fc896d872a21daf213ba94ba7375d88 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Mar 2013 11:05:57 +0530 Subject: [PATCH 10/20] fixes for material request --- patches/march_2013/__init__.py | 0 patches/march_2013/update_po_prevdoc_doctype.py | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 patches/march_2013/__init__.py create mode 100644 patches/march_2013/update_po_prevdoc_doctype.py diff --git a/patches/march_2013/__init__.py b/patches/march_2013/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/patches/march_2013/update_po_prevdoc_doctype.py b/patches/march_2013/update_po_prevdoc_doctype.py new file mode 100644 index 0000000000..35e7a257b4 --- /dev/null +++ b/patches/march_2013/update_po_prevdoc_doctype.py @@ -0,0 +1,6 @@ +import webnotes +def execute(): + webnotes.conn.sql("""update `tabPurchase Order Item` set prevdoc_doctype = 'Material Request' + where prevdoc_doctype = 'Purchase Request'""") + webnotes.conn.sql("""update `tabSupplier Quotation Item` + set prevdoc_doctype = 'Material Request' where prevdoc_doctype = 'Purchase Request'""") \ No newline at end of file From 95a72a7a4acad845ad8039c437b9f5ae94a09269 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Mar 2013 11:07:07 +0530 Subject: [PATCH 11/20] fixes for material request --- patches/patch_list.py | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/patch_list.py b/patches/patch_list.py index 9e5d6f69af..50eb0cdd81 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -201,4 +201,5 @@ patch_list = [ 'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Spartan") # 2013-02-26', "execute:(not webnotes.conn.exists('Role', 'Projects Manager')) and webnotes.doc({'doctype':'Role', 'role_name':'Projects Manager'}).insert()", "patches.february_2013.p09_remove_cancelled_warehouses", + "patches.march_2013.update_po_prevdoc_doctype", ] \ No newline at end of file From 322bd08f26e108e88135064bef251b5049840666 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 12:52:34 +0530 Subject: [PATCH 12/20] allow attachment in batch --- stock/doctype/batch/batch.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/stock/doctype/batch/batch.txt b/stock/doctype/batch/batch.txt index cad4a0db2c..6a6de8b247 100644 --- a/stock/doctype/batch/batch.txt +++ b/stock/doctype/batch/batch.txt @@ -1,15 +1,17 @@ [ { - "creation": "2013-01-10 16:34:25", + "creation": "2013-03-01 08:21:54", "docstatus": 0, - "modified": "2013-01-29 13:40:32", + "modified": "2013-03-01 08:22:16", "modified_by": "Administrator", "owner": "harshada@webnotestech.com" }, { + "allow_attach": 1, "autoname": "field:batch_id", "doctype": "DocType", "document_type": "Master", + "max_attachments": 5, "module": "Stock", "name": "__common__" }, @@ -105,6 +107,15 @@ "oldfieldtype": "Small Text", "read_only": 1 }, + { + "doctype": "DocField", + "fieldname": "file_list", + "fieldtype": "Text", + "hidden": 1, + "label": "File List", + "no_copy": 1, + "print_hide": 1 + }, { "doctype": "DocPerm" } From 1ead851e169da8d7ff6002cec02b432d19674984 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Mar 2013 13:21:29 +0530 Subject: [PATCH 13/20] datatype validation in voucher import tool --- accounts/page/voucher_import_tool/voucher_import_tool.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index b94864c211..1819e07705 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -160,6 +160,12 @@ def import_vouchers(common_values, data, start_idx, import_type): raise Exception doclist = Bean([jv]+details) + + # validate datatype + from core.page.data_import_tool.data_import_tool import check_record + for d in doclist: + check_record(d.fields, d.parenttype) + doclist.submit() messages.append("""

[row #%s] From 57f83ed36b2ae371dbdb971698569ed9317bfe8e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 14:11:56 +0530 Subject: [PATCH 14/20] show leave balance in leave balance report --- hr/report/employee_leave_balance/employee_leave_balance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hr/report/employee_leave_balance/employee_leave_balance.py b/hr/report/employee_leave_balance/employee_leave_balance.py index 6d34c8a8e9..9d859daf23 100644 --- a/hr/report/employee_leave_balance/employee_leave_balance.py +++ b/hr/report/employee_leave_balance/employee_leave_balance.py @@ -33,6 +33,7 @@ def execute(filters=None): for leave_type in leave_types: columns.append(leave_type + " Allocated:Float") columns.append(leave_type + " Taken:Float") + columns.append(leave_type + " Balance:Float") data = {} for d in allocations: @@ -52,5 +53,6 @@ def execute(filters=None): tmp = data.get((fiscal_year, employee.name, leave_type), webnotes._dict()) row.append(tmp.allocation or 0) row.append(tmp.leaves or 0) + row.append((tmp.allocation or 0) - (tmp.leaves or 0)) return columns, result \ No newline at end of file From 483731e06c5d42c565f3692b0602a7e5bcb39eb7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Mar 2013 14:40:40 +0530 Subject: [PATCH 15/20] fixes in attendance control panel --- .../attendance_control_panel.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hr/doctype/attendance_control_panel/attendance_control_panel.py b/hr/doctype/attendance_control_panel/attendance_control_panel.py index dd0deb1784..8b86cee297 100644 --- a/hr/doctype/attendance_control_panel/attendance_control_panel.py +++ b/hr/doctype/attendance_control_panel/attendance_control_panel.py @@ -16,12 +16,8 @@ from __future__ import unicode_literals import webnotes -import webnotes.default - -from webnotes.utils import cint, cstr, date_diff, formatdate, getdate, now -from webnotes.model import db_exists -from webnotes.model.bean import copy_doclist -from webnotes import form, msgprint +from webnotes.utils import cint, cstr, formatdate, getdate +from webnotes import msgprint sql = webnotes.conn.sql @@ -49,13 +45,8 @@ class DocType: # get date list inbetween from date and to date def date_diff_list(self): import datetime - #get from date - att_fr_date = self.doc.att_fr_date and self.doc.att_fr_date or '' - - #get to date - att_to_date = self.doc.att_to_date and self.doc.att_to_date or '' - if att_to_date: + if self.doc.att_to_date: r = (getdate(self.doc.att_to_date)+datetime.timedelta(days=1)-getdate(self.doc.att_fr_date)).days else: r = 1 @@ -65,6 +56,7 @@ class DocType: return dt def get_att_data(self): + import webnotes.defaults fy = webnotes.defaults.get_global_default('fiscal_year') comp = webnotes.defaults.get_user_default('company') From a6acdda09496b85a48ea00a1a96dc3243730f51c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 14:41:32 +0530 Subject: [PATCH 16/20] fixes in calendar event display on desktop --- home/page/desktop/desktop.js | 5 +++-- startup/startup.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/home/page/desktop/desktop.js b/home/page/desktop/desktop.js index c298b68218..87181d8a98 100644 --- a/home/page/desktop/desktop.js +++ b/home/page/desktop/desktop.js @@ -23,9 +23,10 @@ erpnext.desktop.render = function() { module.name = m; module.label = wn._(module.label); module.gradient_css = wn.get_gradient_css(module.color, 45); + module._link = module.link.toLowerCase().replace("/", "-"); $module_icon = $(repl('\ -

\
\ \ @@ -84,7 +85,7 @@ erpnext.desktop.show_pending_notifications = function() { add_circle('module-icon-messages', 'unread_messages', 'Unread Messages'); add_circle('module-icon-support-home', 'open_support_tickets', 'Open Support Tickets'); add_circle('module-icon-todo', 'things_todo', 'Things To Do'); - add_circle('module-icon-calendar', 'todays_events', 'Todays Events'); + add_circle('module-icon-calendar-event', 'todays_events', 'Todays Events'); add_circle('module-icon-projects-home', 'open_tasks', 'Open Tasks'); add_circle('module-icon-questions', 'unanswered_questions', 'Unanswered Questions'); add_circle('module-icon-selling-home', 'open_leads', 'Open Leads'); diff --git a/startup/startup.py b/startup/startup.py index c74c596235..89c0336d17 100644 --- a/startup/startup.py +++ b/startup/startup.py @@ -55,7 +55,7 @@ def get_todays_events(): SELECT COUNT(*) FROM `tabEvent` WHERE owner = %s AND event_type != 'Cancel' - AND event_date = %s""", ( + AND %s between date(starts_on) and date(ends_on)""", ( webnotes.session.user, nowdate())) return todays_events[0][0] From 619dc6fcf8f669d94574a3f3089632258fa49114 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 16:12:37 +0530 Subject: [PATCH 17/20] send support ticket response at the end of all operations --- support/doctype/support_ticket/get_support_mails.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/support/doctype/support_ticket/get_support_mails.py b/support/doctype/support_ticket/get_support_mails.py index a91d483200..d1fe0dc8da 100644 --- a/support/doctype/support_ticket/get_support_mails.py +++ b/support/doctype/support_ticket/get_support_mails.py @@ -36,6 +36,7 @@ class SupportMailbox(POP3Mailbox): return thread_id = mail.get_thread_id() ticket = None + new_ticket = False if thread_id and webnotes.conn.exists("Support Ticket", thread_id): ticket = webnotes.bean("Support Ticket", thread_id) @@ -52,16 +53,17 @@ class SupportMailbox(POP3Mailbox): "status": "Open" }]) ticket.insert() - - if cint(self.email_settings.send_autoreply): - if "mailer-daemon" not in mail.from_email.lower(): - self.send_auto_reply(ticket.doc) + new_ticket = True mail.save_attachments_in_doc(ticket.doc) make(content=mail.content, sender=mail.from_email, subject = ticket.doc.subject, doctype="Support Ticket", name=ticket.doc.name, lead = ticket.doc.lead, contact=ticket.doc.contact, date=mail.date) + + if new_ticket and cint(self.email_settings.send_autoreply) and \ + "mailer-daemon" not in mail.from_email.lower(): + self.send_auto_reply(ticket.doc) def send_auto_reply(self, d): signature = self.email_settings.fields.get('support_signature') or '' From a10461e16c9c58d66bed5c4bae6451b28ff3b2aa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 16:12:50 +0530 Subject: [PATCH 18/20] minor fix in purchase receipt --- stock/doctype/purchase_receipt/purchase_receipt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 88003ca682..b2f00a7efc 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -214,7 +214,8 @@ class DocType(BuyingController): def validate_inspection(self): for d in getlist(self.doclist, 'purchase_receipt_details'): #Enter inspection date for all items that require inspection - ins_reqd = sql("select inspection_required from `tabItem` where name = %s", (d.item_code), as_dict = 1) + ins_reqd = sql("select inspection_required from `tabItem` where name = %s", + (d.item_code,), as_dict = 1) ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No' if ins_reqd == 'Yes' and not d.qa_no: msgprint("Item: " + d.item_code + " requires QA Inspection. Please enter QA No or report to authorized person to create Quality Inspection") From 37ef553f6bcfff67e717d4e8904e106cadc2b815 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Mar 2013 17:39:41 +0530 Subject: [PATCH 19/20] fixes for sub_contracting --- .../purchase_invoice/purchase_invoice.py | 17 +++++++++-------- .../purchase_receipt/purchase_receipt.py | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index be55e8a730..a39df410cc 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -518,16 +518,17 @@ class DocType(BuyingController): def on_update(self): pass + def update_raw_material_cost(self): if self.sub_contracted_items: for d in self.doclist.get({"parentfield": "entries"}): - rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity - from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 - and is_active = 1 """, (d.item_code,)) - rm_cost = rm_cost and flt(rm_cost[0][0]) or 0 + rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity + from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 + and is_active = 1 """, (d.item_code,)) + rm_cost = rm_cost and flt(rm_cost[0][0]) or 0 - d.conversion_factor = d.conversion_factor or webnotes.conn.get_value( - "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom}, - "conversion_factor") or 1 + d.conversion_factor = d.conversion_factor or webnotes.conn.get_value( + "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom}, + "conversion_factor") or 1 - d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor) + d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 88003ca682..c216abe687 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -289,7 +289,7 @@ class DocType(BuyingController): self.make_gl_entries() def validate_for_subcontracting(self): - if self.sub_contracted_items and self.purchase_items and not self.doc.is_subcontracted: + if not self.doc.is_subcontracted and self.sub_contracted_items: webnotes.msgprint(_("""Please enter whether Purchase Recipt is made for subcontracting or purchasing, in 'Is Subcontracted' field"""), raise_exception=1) @@ -299,7 +299,7 @@ class DocType(BuyingController): def update_raw_materials_supplied(self): self.doclist = self.doc.clear_table(self.doclist, 'pr_raw_material_details') - if self.sub_contracted_items: + if self.doc.is_subcontracted=="Yes": for item in self.doclist.get({"parentfield": "purchase_receipt_details"}): if item.item_code in self.sub_contracted_items: self.add_bom_items(item) From 3e157ec2ea92a477a84f0d346317497aa58ac4bc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 17:55:37 +0530 Subject: [PATCH 20/20] show pin code after state instead of after city in address display --- utilities/transaction_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index b84b3742a3..61486c50d5 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -75,7 +75,7 @@ class TransactionBase(DocListController): details = webnotes.conn.sql("select name, address_line1, address_line2, city, country, pincode, state, phone, fax from `tabAddress` where %s and docstatus != 2 order by is_primary_address desc limit 1" % cond, as_dict = 1) extract = lambda x: details and details[0] and details[0].get(x,'') or '' - address_fields = [('','address_line1'),('\n','address_line2'),('\n','city'),(' ','pincode'),('\n','state'),('\n','country'),('\nPhone: ','phone'),('\nFax: ', 'fax')] + address_fields = [('','address_line1'),('\n','address_line2'),('\n','city'),('\n','state'),(' ','pincode'),('\n','country'),('\nPhone: ','phone'),('\nFax: ', 'fax')] address_display = ''.join([a[0]+extract(a[1]) for a in address_fields if extract(a[1])]) if address_display.startswith('\n'): address_display = address_display[1:]