From 9f43fc50ad5b8b8026e5be7a6b33e076b983a3f9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Apr 2013 12:12:47 +0530 Subject: [PATCH 01/10] [website] [product list] image clickable --- setup/doctype/item_group/item_group.txt | 33 +++++++++++---------- website/templates/html/product_in_list.html | 8 +++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/setup/doctype/item_group/item_group.txt b/setup/doctype/item_group/item_group.txt index d9c6ffeddac..a8da12c8f3f 100644 --- a/setup/doctype/item_group/item_group.txt +++ b/setup/doctype/item_group/item_group.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-23 20:00:16", + "creation": "2013-03-28 10:35:29", "docstatus": 0, - "modified": "2013-03-20 15:09:28", + "modified": "2013-04-01 12:06:52", "modified_by": "Administrator", "owner": "Administrator" }, @@ -124,6 +124,7 @@ "label": "Description" }, { + "depends_on": "show_in_website", "doctype": "DocField", "fieldname": "item_website_specifications", "fieldtype": "Table", @@ -181,20 +182,6 @@ "no_copy": 1, "print_hide": 1 }, - { - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "role": "System Manager", - "write": 1 - }, - { - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "role": "Material Master Manager", - "write": 1 - }, { "amend": 0, "cancel": 0, @@ -210,5 +197,19 @@ "doctype": "DocPerm", "role": "Material User", "write": 0 + }, + { + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "role": "System Manager", + "write": 1 + }, + { + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "role": "Material Master Manager", + "write": 1 } ] \ No newline at end of file diff --git a/website/templates/html/product_in_list.html b/website/templates/html/product_in_list.html index 97de5963660..bc6260795bd 100644 --- a/website/templates/html/product_in_list.html +++ b/website/templates/html/product_in_list.html @@ -1,10 +1,12 @@
- {% if website_image %} + + {%- if website_image -%} - {% else %} + {%- else -%} {% include 'html/product_missing_image.html' %} - {% endif %} + {%- endif -%} +

{{ item_name }}

From 1013e779577e25b0bd855123b630e76ab99d4b6a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Apr 2013 12:18:36 +0530 Subject: [PATCH 02/10] fixes in checking print_hide property in standard print format --- .../sales_taxes_and_charges_master.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js index b1cbbdcbfcc..1e72010f26f 100644 --- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js +++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js @@ -53,16 +53,14 @@ cur_frm.pformat.other_charges= function(doc){ var new_val = flt(val)/flt(doc.conversion_rate); return new_val; } + + function print_hide(fieldname) { + var doc_field = wn.meta.get_docfield(doc.doctype, fieldname, doc.name); + return doc_field.print_hide; + } + out =''; if (!doc.print_without_amount) { - print_hide_dict = {}; - for(var i in locals['DocField']) { - var doc_field = locals['DocField'][i]; - if(doc_field.fieldname) { - print_hide_dict[doc_field.fieldname] = doc_field.print_hide; - } - } - var cl = getchildren('Sales Taxes and Charges',doc.name,'other_charges'); // outer table @@ -71,7 +69,7 @@ cur_frm.pformat.other_charges= function(doc){ // main table out +=''; - if(!print_hide_dict['net_total']) { + if(!print_hide('net_total')) { out +=make_row('Net Total',convert_rate(doc.net_total),1); } @@ -84,15 +82,15 @@ cur_frm.pformat.other_charges= function(doc){ } // grand total - if(!print_hide_dict['grand_total_export']) { + if(!print_hide('grand_total_export')) { out += make_row('Grand Total',doc.grand_total_export,1); } - if(!print_hide_dict['rounded_total_export']) { + if(!print_hide('rounded_total_export')) { out += make_row('Rounded Total',doc.rounded_total_export,1); } - if(doc.in_words_export && !print_hide_dict['in_words_export']){ + if(doc.in_words_export && !print_hide('in_words_export')){ out +='
'; out += ''; out += '' From eaeb50effa304dea870285640840396a96c208e3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Apr 2013 15:40:50 +0530 Subject: [PATCH 03/10] [fixes] small issue fixed in sales taxes and charges --- .../sales_taxes_and_charges_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py index 953269c50e9..6cd2b4ffaa1 100644 --- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py +++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py @@ -24,7 +24,7 @@ class DocType: def get_rate(self, arg): from webnotes.model.code import get_obj - return get_obj('Sales Common').get_rate(arg, self) + return get_obj('Sales Common').get_rate(arg) def update_other_default_charges(self): webnotes.conn.sql("update `tabSales Taxes and Charges Master` set is_default = 0 where ifnull(is_default,0) = 1 and name != '%s' and company = '%s'" % (self.doc.name, self.doc.company)) From 72b28807d2265f68bb6943fde4a592e5347efdab Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 1 Apr 2013 16:40:19 +0530 Subject: [PATCH 04/10] [setup] [feature] Update Manager for self hosted applications based on wnframework --- setup/page/setup/setup.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js index e59a18ab990..4a97b345a2c 100644 --- a/setup/page/setup/setup.js +++ b/setup/page/setup/setup.js @@ -199,6 +199,18 @@ wn.module_page["Setup"] = [ }, ] }, + { + title: wn._("Update Manager"), + icon: "icon-magnet", + right: true, + items: [ + { + "page":"update-this-app", + label: wn._("Update This Application"), + "description":wn._("Apply latest updates and patches to this app") + }, + ] + }, ] pscript['onload_Setup'] = function(wrapper) { From bdedd555caa35374f4446b8de414e485378e933a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 1 Apr 2013 16:51:33 +0530 Subject: [PATCH 05/10] [setup] [update manager] renamed update-this-app page to update-manager --- setup/page/setup/setup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js index 4a97b345a2c..4ab7578850a 100644 --- a/setup/page/setup/setup.js +++ b/setup/page/setup/setup.js @@ -205,7 +205,7 @@ wn.module_page["Setup"] = [ right: true, items: [ { - "page":"update-this-app", + "page":"update-manager", label: wn._("Update This Application"), "description":wn._("Apply latest updates and patches to this app") }, From 2f20a7ac96c4ff5621815e8566966e29715297e5 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Apr 2013 17:23:43 +0530 Subject: [PATCH 06/10] [patch][serial no] for striped serial nos --- patches/april_2013/__init__.py | 0 .../p01_update_serial_no_valuation_rate.py | 26 +++++++++++++++++++ .../march_2013/p07_update_valuation_rate.py | 4 +-- .../p10_update_against_expense_account.py | 8 +++--- patches/patch_list.py | 1 + .../landed_cost_wizard/landed_cost_wizard.py | 11 ++++---- stock/doctype/stock_ledger/stock_ledger.py | 5 ++-- 7 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 patches/april_2013/__init__.py create mode 100644 patches/april_2013/p01_update_serial_no_valuation_rate.py diff --git a/patches/april_2013/__init__.py b/patches/april_2013/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/patches/april_2013/p01_update_serial_no_valuation_rate.py b/patches/april_2013/p01_update_serial_no_valuation_rate.py new file mode 100644 index 00000000000..10584734785 --- /dev/null +++ b/patches/april_2013/p01_update_serial_no_valuation_rate.py @@ -0,0 +1,26 @@ +import webnotes +from webnotes.utils import cstr +from stock.stock_ledger import update_entries_after + +def execute(): + pr_items = webnotes.conn.sql("""select item_code, warehouse, serial_no, valuation_rate, name + from `tabPurchase Receipt Item` where ifnull(serial_no, '') != '' and docstatus = 1""", + as_dict=True) + + item_warehouse = [] + + for item in pr_items: + serial_nos = cstr(item.serial_no).strip().split("\n") + serial_nos = map(lambda x: x.strip(), serial_nos) + + webnotes.conn.sql("""update `tabPurchase Receipt Item` set serial_no = %s + where name = %s""", ("\n".join(serial_nos), item.name)) + + webnotes.conn.sql("""update `tabSerial No` set purchase_rate = %s where name in (%s)""" % + ('%s', ', '.join(['%s']*len(serial_nos))), tuple([item.valuation_rate] + serial_nos)) + + if [item.item_code, item.warehouse] not in item_warehouse: + item_warehouse.append([item.item_code, item.warehouse]) + + for d in item_warehouse: + update_entries_after({"item_code": d[0], "warehouse": d[1] }) \ No newline at end of file diff --git a/patches/march_2013/p07_update_valuation_rate.py b/patches/march_2013/p07_update_valuation_rate.py index 51e556b328b..7cc3e1137a3 100644 --- a/patches/march_2013/p07_update_valuation_rate.py +++ b/patches/march_2013/p07_update_valuation_rate.py @@ -8,6 +8,6 @@ def execute(): pi.update_raw_material_cost() pi.update_valuation_rate("entries") for item in pi.doclist.get({"parentfield": "entries"}): - webnotes.conn.set_value("Purchase Invoice Item", item.name, "valuation_rate", - item.valuation_rate) + webnotes.conn.sql("""update `tabPurchase Invoice Item` set valuation_rate = %s + where name = %s""", (item.valuation_rate, item.name)) \ No newline at end of file diff --git a/patches/march_2013/p10_update_against_expense_account.py b/patches/march_2013/p10_update_against_expense_account.py index d1bad5cfeda..3506ac4936d 100644 --- a/patches/march_2013/p10_update_against_expense_account.py +++ b/patches/march_2013/p10_update_against_expense_account.py @@ -5,7 +5,7 @@ def execute(): where docstatus = 1 and ifnull(against_expense_account, '') = ''""") for pi in pi_list: - pi_obj = get_obj("Purchase Invoice", pi[0], with_children=1) - pi_obj.set_against_expense_account() - webnotes.conn.set_value("Purchase Invoice", pi[0], - "against_expense_account", pi_obj.doc.against_expense_account) \ No newline at end of file + pi_obj = get_obj("Purchase Invoice", pi[0], with_children=1) + pi_obj.set_against_expense_account() + webnotes.conn.sql("""update `tabPurchase Invoice` set against_expense_account = %s + where name = %s""", (pi_obj.doc.against_expense_account, pi[0])) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 905ea290c90..544fc957e9a 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -227,4 +227,5 @@ patch_list = [ "patches.march_2013.p10_update_against_expense_account", "patches.march_2013.p11_update_attach_files", "patches.march_2013.p12_set_item_tax_rate_in_json", + "patches.april_2013.p01_update_serial_no_valuation_rate", ] \ No newline at end of file diff --git a/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py index 1fb7b9a0164..e5fd12ca624 100644 --- a/stock/doctype/landed_cost_wizard/landed_cost_wizard.py +++ b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py @@ -212,7 +212,8 @@ class DocType: if flt(d.qty): d.valuation_rate = (flt(d.purchase_rate) + (flt(d.rm_supp_cost)/flt(d.qty)) + (flt(d.item_tax_amount)/flt(d.qty))) / flt(d.conversion_factor) d.save() - self.update_serial_no(d.serial_no, d.valuation_rate) + if d.serial_no: + self.update_serial_no(d.serial_no, d.valuation_rate) sql("update `tabStock Ledger Entry` set incoming_rate = '%s' where voucher_detail_no = '%s'"%(flt(d.valuation_rate), d.name)) res = sql("""select item_code, warehouse, posting_date, posting_time @@ -226,10 +227,10 @@ class DocType: def update_serial_no(self, sr_no, rate): """ update valuation rate in serial no""" - sr_no = cstr(sr_no).split('\n') - for d in sr_no: - sql("update `tabSerial No` set purchase_rate = %s where name = %s", (rate, d)) - + sr_no = map(lambda x: x.strip(), cstr(sr_no).split('\n')) + + webnotes.conn.sql("""update `tabSerial No` set purchase_rate = %s where name in (%s)""" % + ('%s', ', '.join(['%s']*len(sr_no))), tuple([rate] + sr_no)) def update_landed_cost(self): """ diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index fcb4a54a47b..a90ed9041b3 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -38,10 +38,10 @@ class DocType: for d in getlist(obj.doclist, table_name): if d.serial_no: - d.serial_no = cstr(d.serial_no).strip().replace(',', '\n') + serial_nos = cstr(d.serial_no).strip().replace(',', '\n').split('\n') + d.serial_nos = ", ".join(map(lambda x: x.strip(), serial_nos)) d.save() - def validate_serial_no_warehouse(self, obj, fname): for d in getlist(obj.doclist, fname): wh = d.warehouse or d.s_warehouse @@ -84,6 +84,7 @@ class DocType: item_details = webnotes.conn.sql("""select item_group, warranty_period from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) """ %(d.item_code), as_dict=1) + webnotes.errprint([d.item_code, d.valuation_rate]) s.purchase_document_type = obj.doc.doctype s.purchase_document_no = obj.doc.name From 94d162269156cb0504b7ce50db95afbf1580f8ae Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Apr 2013 17:25:28 +0530 Subject: [PATCH 07/10] [patch][serial no] for striped serial nos --- stock/doctype/stock_ledger/stock_ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index a90ed9041b3..80eaaeace3e 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -39,7 +39,7 @@ class DocType: for d in getlist(obj.doclist, table_name): if d.serial_no: serial_nos = cstr(d.serial_no).strip().replace(',', '\n').split('\n') - d.serial_nos = ", ".join(map(lambda x: x.strip(), serial_nos)) + d.serial_nos = "\n".join(map(lambda x: x.strip(), serial_nos)) d.save() def validate_serial_no_warehouse(self, obj, fname): From 2a8b2c13565260c9741be3cf5d5deb8ba3b6ad56 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Apr 2013 17:49:15 +0530 Subject: [PATCH 08/10] [patch][serial no] for striped serial nos --- .../p01_update_serial_no_valuation_rate.py | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/patches/april_2013/p01_update_serial_no_valuation_rate.py b/patches/april_2013/p01_update_serial_no_valuation_rate.py index 10584734785..2ea0c26a557 100644 --- a/patches/april_2013/p01_update_serial_no_valuation_rate.py +++ b/patches/april_2013/p01_update_serial_no_valuation_rate.py @@ -3,6 +3,8 @@ from webnotes.utils import cstr from stock.stock_ledger import update_entries_after def execute(): + webnotes.conn.auto_commit_on_many_writes = 1 + pr_items = webnotes.conn.sql("""select item_code, warehouse, serial_no, valuation_rate, name from `tabPurchase Receipt Item` where ifnull(serial_no, '') != '' and docstatus = 1""", as_dict=True) @@ -13,14 +15,21 @@ def execute(): serial_nos = cstr(item.serial_no).strip().split("\n") serial_nos = map(lambda x: x.strip(), serial_nos) - webnotes.conn.sql("""update `tabPurchase Receipt Item` set serial_no = %s - where name = %s""", ("\n".join(serial_nos), item.name)) + if cstr(item.serial_no) != "\n".join(serial_nos): + webnotes.conn.sql("""update `tabPurchase Receipt Item` set serial_no = %s + where name = %s""", ("\n".join(serial_nos), item.name)) + + if [item.item_code, item.warehouse] not in item_warehouse: + item_warehouse.append([item.item_code, item.warehouse]) - webnotes.conn.sql("""update `tabSerial No` set purchase_rate = %s where name in (%s)""" % - ('%s', ', '.join(['%s']*len(serial_nos))), tuple([item.valuation_rate] + serial_nos)) - - if [item.item_code, item.warehouse] not in item_warehouse: - item_warehouse.append([item.item_code, item.warehouse]) + webnotes.conn.sql("""update `tabSerial No` set purchase_rate = %s + where name in (%s)""" % ('%s', ', '.join(['%s']*len(serial_nos))), + tuple([item.valuation_rate] + serial_nos)) for d in item_warehouse: - update_entries_after({"item_code": d[0], "warehouse": d[1] }) \ No newline at end of file + try: + update_entries_after({"item_code": d[0], "warehouse": d[1] }) + except: + continue + + webnotes.conn.auto_commit_on_many_writes = 0 \ No newline at end of file From 1a5d97e6b654bebddb32a88ef336cdb0b70a18c7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Apr 2013 18:46:42 +0530 Subject: [PATCH 09/10] fixes in stock ledger --- stock/doctype/stock_ledger/stock_ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index 80eaaeace3e..469c94bb2fa 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -39,7 +39,7 @@ class DocType: for d in getlist(obj.doclist, table_name): if d.serial_no: serial_nos = cstr(d.serial_no).strip().replace(',', '\n').split('\n') - d.serial_nos = "\n".join(map(lambda x: x.strip(), serial_nos)) + d.serial_no = "\n".join(map(lambda x: x.strip(), serial_nos)) d.save() def validate_serial_no_warehouse(self, obj, fname): From 4b6052b57b4d82f5ceb9e180f2fb213e88baf5fc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 1 Apr 2013 18:52:47 +0530 Subject: [PATCH 10/10] [stock] [fix] serial nos scrub method --- stock/doctype/stock_ledger/stock_ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index 80eaaeace3e..469c94bb2fa 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -39,7 +39,7 @@ class DocType: for d in getlist(obj.doclist, table_name): if d.serial_no: serial_nos = cstr(d.serial_no).strip().replace(',', '\n').split('\n') - d.serial_nos = "\n".join(map(lambda x: x.strip(), serial_nos)) + d.serial_no = "\n".join(map(lambda x: x.strip(), serial_nos)) d.save() def validate_serial_no_warehouse(self, obj, fname):
In Words