[minor] fixes after item price move
diff --git a/patches/october_2013/p07_rename_for_territory.py b/patches/october_2013/p07_rename_for_territory.py
index 2317002..c4b6745 100644
--- a/patches/october_2013/p07_rename_for_territory.py
+++ b/patches/october_2013/p07_rename_for_territory.py
@@ -14,8 +14,9 @@
webnotes.reload_doc("setup", "doctype", "applicable_territory")
- if os.path.exists("app/setup/doctype/for_territory"):
- os.system("rm -rf app/setup/doctype/for_territory")
+ path = os.path.join(get_base_path(), "app", "setup", "doctype", "for_territory")
+ if os.path.exists(path):
+ 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
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 0000000..4169d96
--- /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 67affb6..0cc393e 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -229,4 +229,5 @@
"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/stock/doctype/item_price/item_price.py b/stock/doctype/item_price/item_price.py
index be235de..b398326 100644
--- a/stock/doctype/item_price/item_price.py
+++ b/stock/doctype/item_price/item_price.py
@@ -7,7 +7,7 @@
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 @@
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 43694da..73b8a8c 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 = [
[