From b03f870441a7e1ff91538403c2ad13a9050275f6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 4 Nov 2013 15:22:50 +0530 Subject: [PATCH] Merge branch '1310' of github.com:webnotes/erpnext --- patches/october_2013/p07_rename_for_territory.py | 2 +- .../p08_cleanup_after_item_price_module_change.py | 13 +++++++++++++ patches/patch_list.py | 1 + setup/page/setup_wizard/setup_wizard.py | 8 ++++---- stock/doctype/item_price/item_price.py | 12 ++++++++---- stock/doctype/item_price/test_item_price.py | 6 +++--- 6 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 patches/october_2013/p08_cleanup_after_item_price_module_change.py diff --git a/patches/october_2013/p07_rename_for_territory.py b/patches/october_2013/p07_rename_for_territory.py index 240a957321..520f3bc91c 100644 --- a/patches/october_2013/p07_rename_for_territory.py +++ b/patches/october_2013/p07_rename_for_territory.py @@ -20,4 +20,4 @@ def execute(): os.system("rm -rf {path}".format(path=path)) if webnotes.conn.exists("DocType", "For Territory"): - webnotes.delete_doc("DocType", "For Territory") \ No newline at end of file + webnotes.delete_doc("DocType", "For Territory") diff --git a/patches/october_2013/p08_cleanup_after_item_price_module_change.py b/patches/october_2013/p08_cleanup_after_item_price_module_change.py new file mode 100644 index 0000000000..4169d96b3e --- /dev/null +++ b/patches/october_2013/p08_cleanup_after_item_price_module_change.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes, os + +def execute(): + from webnotes.utils import get_base_path + + for dt in ("item_price", "price_list"): + path = os.path.join(get_base_path(), "app", "setup", "doctype", dt) + if os.path.exists(path): + os.system("rm -rf {path}".format(path=path)) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index e55991b058..1581841872 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -236,4 +236,5 @@ patch_list = [ "patches.october_2013.p06_update_control_panel_and_global_defaults", "patches.october_2013.p07_rename_for_territory", "patches.june_2013.p07_taxes_price_list_for_territory", + "patches.october_2013.p08_cleanup_after_item_price_module_change", ] \ No newline at end of file diff --git a/setup/page/setup_wizard/setup_wizard.py b/setup/page/setup_wizard/setup_wizard.py index 7ed930073d..61af55b98b 100644 --- a/setup/page/setup_wizard/setup_wizard.py +++ b/setup/page/setup_wizard/setup_wizard.py @@ -124,7 +124,9 @@ def set_defaults(args): 'default_currency': args.get('currency'), 'default_company':args.get('company_name'), 'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"), - "float_precision": 4 + "float_precision": 3, + "country": args.get("country"), + "time_zone": args.get("time_zone") }) global_defaults.save() @@ -164,9 +166,7 @@ def set_defaults(args): # control panel cp = webnotes.doc("Control Panel", "Control Panel") - for k in ['country', 'timezone', 'company_name']: - cp.fields[k] = args[k] - + cp.company_name = args["company_name"] cp.save() def create_feed_and_todo(): diff --git a/stock/doctype/item_price/item_price.py b/stock/doctype/item_price/item_price.py index be235de27c..b398326d02 100644 --- a/stock/doctype/item_price/item_price.py +++ b/stock/doctype/item_price/item_price.py @@ -7,7 +7,7 @@ from __future__ import unicode_literals import webnotes from webnotes import _ -class ItemPriceDuplicateItem(Exception): pass +class ItemPriceDuplicateItem(webnotes.ValidationError): pass class DocType: def __init__(self, d, dl): @@ -30,6 +30,10 @@ class DocType: if webnotes.conn.sql("""select name from `tabItem Price` where item_code=%s and price_list=%s and name!=%s""", (self.doc.item_code, self.doc.price_list, self.doc.name)): - webnotes.throw(_("Duplicate Item: ") + self.doc.item_code + - _(" already available in Price List: ") + self.doc.price_list, - ItemPriceDuplicateItem) \ No newline at end of file + webnotes.throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{ + "duplicate_item": _("Duplicate Item"), + "item_code": self.doc.item_code, + "already": _("already available in Price List"), + "price_list": self.doc.price_list + }), ItemPriceDuplicateItem) + \ No newline at end of file diff --git a/stock/doctype/item_price/test_item_price.py b/stock/doctype/item_price/test_item_price.py index 43694da8fa..73b8a8ccec 100644 --- a/stock/doctype/item_price/test_item_price.py +++ b/stock/doctype/item_price/test_item_price.py @@ -4,12 +4,12 @@ from __future__ import unicode_literals import unittest import webnotes -from setup.doctype.item_price.item_price import ItemPriceDuplicateItem class TestItem(unittest.TestCase): def test_duplicate_item(self): - item_price = webnotes.bean(copy=test_records[0]) - self.assertRaises(ItemPriceDuplicateItem, item_price.insert) + from stock.doctype.item_price.item_price import ItemPriceDuplicateItem + bean = webnotes.bean(copy=test_records[0]) + self.assertRaises(ItemPriceDuplicateItem, bean.insert) test_records = [ [