From 031b7b3069fc647bf32059cf502d6c64285b3f18 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 May 2013 12:19:57 +0530 Subject: [PATCH 1/6] [fixes] repost stock: commit after every 20 --- patches/may_2013/repost_stock_for_no_posting_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/may_2013/repost_stock_for_no_posting_time.py b/patches/may_2013/repost_stock_for_no_posting_time.py index b4d52ec4fc..489511c53e 100644 --- a/patches/may_2013/repost_stock_for_no_posting_time.py +++ b/patches/may_2013/repost_stock_for_no_posting_time.py @@ -29,6 +29,6 @@ def execute(): except: pass i += 1 - if i%50 == 0: + if i%20 == 0: webnotes.conn.sql("commit") webnotes.conn.sql("start transaction") \ No newline at end of file From 6b2aa7ed0dcd185aa72bece28af0bf1e56b1f742 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 20 May 2013 13:43:50 +0530 Subject: [PATCH 2/6] [country info] [fix] added additional timezones + fixed fresh install --- public/js/complete_setup.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/public/js/complete_setup.js b/public/js/complete_setup.js index f5d06722c6..f0b21c8516 100644 --- a/public/js/complete_setup.js +++ b/public/js/complete_setup.js @@ -40,7 +40,7 @@ $.extend(erpnext.complete_setup, { {fieldname:'country', label: 'Country', reqd:1, options: "", fieldtype: 'Select'}, {fieldname:'currency', label: 'Default Currency', reqd:1, - options: "Currency", fieldtype: 'Link'}, + options: "", fieldtype: 'Select'}, {fieldname:'timezone', label: 'Time Zone', reqd:1, options: "", fieldtype: 'Select'}, {fieldname:'industry', label: 'Industry', reqd:1, @@ -55,11 +55,17 @@ $.extend(erpnext.complete_setup, { } wn.call({ - method:"webnotes.country_info.get_all", + method:"webnotes.country_info.get_country_timezone_info", callback: function(data) { - erpnext.country_info = data.message; + erpnext.country_info = data.message.country_info; + erpnext.all_timezones = data.message.all_timezones; d.get_input("country").empty() - .add_options([""].concat(keys(data.message).sort())); + .add_options([""].concat(keys(erpnext.country_info).sort())); + d.get_input("currency").empty() + .add_options(wn.utils.unique([""].concat($.map(erpnext.country_info, + function(opts, country) { return opts.currency; }))).sort()); + d.get_input("timezone").empty() + .add_options([""].concat(erpnext.all_timezones)); } }) @@ -82,19 +88,15 @@ $.extend(erpnext.complete_setup, { var country = d.fields_dict.country.input.value; var $timezone = $(d.fields_dict.timezone.input); $timezone.empty(); + // add country specific timezones first if(country){ - var timezone_list = erpnext.country_info[country].timezones; - if(timezone_list.length==0) { - timezone_list = $.map(erpnext.country_info, function(m) { - return m.timezones - }); - } - $timezone.empty().add_options(timezone_list); - - console.log(d.get_input("currency")) + var timezone_list = erpnext.country_info[country].timezones || []; + $timezone.add_options(timezone_list.sort()); d.get_input("currency").val(erpnext.country_info[country].currency); } + // add all timezones at the end, so that user has the option to change it to any timezone + $timezone.add_options([""].concat(erpnext.all_timezones)); }; @@ -127,5 +129,5 @@ $.extend(erpnext.complete_setup, { 'Finance', 'Food and Beverage', 'Government', 'Healthcare', 'Hospitality', 'Information Technology', 'Insurance', 'Machinery', 'Manufacturing', 'Media', 'Not For Profit', 'Recreation', 'Retail', 'Shipping', 'Technology', - 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'], + 'Telecommunications', 'Transportation', 'Trading', 'Utilities', 'Other'], }); \ No newline at end of file From fdefe0750aae179a6afe93e8c01582dd25ef9eb4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 May 2013 13:59:24 +0530 Subject: [PATCH 3/6] [fixes] item valuation rate in pur cycle --- controllers/buying_controller.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 28d2db646b..25efe4dbd3 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -367,13 +367,14 @@ class BuyingController(StockController): 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((flt(d.purchase_rate, self.precision.item.purchase_rate) or - flt(d.rate, self.precision.item.rate) + + d.valuation_rate = flt(((flt(d.purchase_rate, self.precision.item.purchase_rate) or + flt(d.rate, self.precision.item.rate)) + (flt(d.item_tax_amount, self.precision.item.item_tax_amount) + flt(d.rm_supp_cost, self.precision.item.rm_supp_cost)) / flt(d.qty, self.precision.item.qty)) / flt(d.conversion_factor, self.precision.item.conversion_factor), - self.precision.item.valuation_rate) + self.precision.item.valuation_rate) + else: d.valuation_rate = 0.0 From 9053cbc9f83b2ec70372d24d93ecba45bb0b7043 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 May 2013 15:28:44 +0530 Subject: [PATCH 4/6] [fixes][patch] update valuation rate in purchase cycle and repost patch --- controllers/buying_controller.py | 1 - patches/may_2013/p02_update_valuation_rate.py | 48 +++++++++++++++++++ patches/patch_list.py | 1 + 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 patches/may_2013/p02_update_valuation_rate.py diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 25efe4dbd3..3deda0284b 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -374,7 +374,6 @@ class BuyingController(StockController): flt(d.qty, self.precision.item.qty)) / flt(d.conversion_factor, self.precision.item.conversion_factor), self.precision.item.valuation_rate) - else: d.valuation_rate = 0.0 diff --git a/patches/may_2013/p02_update_valuation_rate.py b/patches/may_2013/p02_update_valuation_rate.py new file mode 100644 index 0000000000..d538d609dd --- /dev/null +++ b/patches/may_2013/p02_update_valuation_rate.py @@ -0,0 +1,48 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import unicode_literals +import webnotes +def execute(): + from stock.stock_ledger import update_entries_after + item_warehouse = [] + # update valuation_rate in transaction + doctypes = {"Purchase Receipt": "purchase_receipt_details", + "Purchase Invoice": "entries"} + + for dt in doctypes: + for d in webnotes.conn.sql("""select name from `tab%s` + where modified >= '2013-05-09' and docstatus=1""" % dt): + rec = webnotes.get_obj(dt, d[0]) + rec.update_valuation_rate(doctypes[dt]) + + for item in rec.doclist.get({"parentfield": doctypes[dt]}): + webnotes.conn.sql("""update `tab%s Item` set valuation_rate = %s + where name = %s"""% (dt, '%s', '%s'), tuple([item.valuation_rate, item.name])) + + if dt == "Purchase Receipt": + webnotes.conn.sql("""update `tabStock Ledger Entry` set incoming_rate = %s + where voucher_detail_no = %s""", (item.valuation_rate, item.name)) + if [item.item_code, item.warehouse] not in item_warehouse: + item_warehouse.append([item.item_code, item.warehouse]) + + for d in item_warehouse: + try: + update_entries_after({"item_code": d[0], "warehouse": d[1], + "posting_date": "2013-01-01", "posting_time": "00:05:00"}) + webnotes.conn.commit() + except: + pass \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 16100097ce..bd7acb2fc6 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -248,4 +248,5 @@ patch_list = [ "patches.april_2013.p08_price_list_country", "patches.may_2013.repost_stock_for_no_posting_time", "patches.may_2013.p01_conversion_factor_and_aii", + "patches.may_2013.p02_update_valuation_rate", ] \ No newline at end of file From f8525fea063665a7078dc1a2ef43eaece34ec169 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 May 2013 15:30:02 +0530 Subject: [PATCH 5/6] [fixes][patch] update valuation rate in purchase cycle and repost patch --- patches/may_2013/p02_update_valuation_rate.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/patches/may_2013/p02_update_valuation_rate.py b/patches/may_2013/p02_update_valuation_rate.py index d538d609dd..280473ccef 100644 --- a/patches/may_2013/p02_update_valuation_rate.py +++ b/patches/may_2013/p02_update_valuation_rate.py @@ -20,8 +20,7 @@ def execute(): from stock.stock_ledger import update_entries_after item_warehouse = [] # update valuation_rate in transaction - doctypes = {"Purchase Receipt": "purchase_receipt_details", - "Purchase Invoice": "entries"} + doctypes = {"Purchase Receipt": "purchase_receipt_details", "Purchase Invoice": "entries"} for dt in doctypes: for d in webnotes.conn.sql("""select name from `tab%s` From a35466b00862d0c5feb05443b37b8c665ce25e61 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 20 May 2013 18:32:06 +0530 Subject: [PATCH 6/6] [price list] on deletion of price list, delete all item price record for the same price list --- setup/doctype/price_list/price_list.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py index ae49bf868d..5c03a3a853 100644 --- a/setup/doctype/price_list/price_list.py +++ b/setup/doctype/price_list/price_list.py @@ -33,3 +33,6 @@ class DocType: msgprint(_("""Please check "Valid For All Countries" or \ enter atlease one row in the "Countries" table."""), raise_exception=True) + def on_trash(self): + webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""", + self.doc.name) \ No newline at end of file