From 345c8fbfa29dd51e7f0a637ec50818dd7b975b16 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 29 Apr 2013 14:35:11 +0530 Subject: [PATCH 1/2] [patch] rebuild sales browser --- patches/april_2013/rebuild_sales_browser.py | 4 ++++ patches/patch_list.py | 1 + 2 files changed, 5 insertions(+) create mode 100644 patches/april_2013/rebuild_sales_browser.py diff --git a/patches/april_2013/rebuild_sales_browser.py b/patches/april_2013/rebuild_sales_browser.py new file mode 100644 index 0000000000..917ae68467 --- /dev/null +++ b/patches/april_2013/rebuild_sales_browser.py @@ -0,0 +1,4 @@ +import webnotes +def execute(): + from patches.january_2013 import rebuild_tree + rebuild_tree.execute() \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index a6dd0a217b..1b874d63ff 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -247,4 +247,5 @@ patch_list = [ "execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')", "patches.april_2013.p06_default_cost_center", "execute:webnotes.reset_perms('File Data')", + "patches.april_2013.rebuild_sales_browser", ] \ No newline at end of file From 7ee7eae3ae8848eb597bcab6557dc278fbb6784b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 29 Apr 2013 15:10:39 +0530 Subject: [PATCH 2/2] [item][validation] some validation only after saving --- stock/doctype/item/item.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 4767742e3e..fce6f32543 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -55,12 +55,13 @@ class DocType(DocListController): ch.conversion_factor = 1 def check_stock_uom_with_bin(self): - bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s", - self.doc.item_code) - if self.doc.stock_uom and bin and cstr(bin[0][0]) \ - and cstr(bin[0][0]) != cstr(self.doc.stock_uom): - msgprint(_("Please Update Stock UOM with the help of Stock UOM Replace Utility."), - raise_exception=1) + if not self.doc.__islocal: + bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s", + self.doc.name) + if self.doc.stock_uom and bin and cstr(bin[0][0]) \ + and cstr(bin[0][0]) != cstr(self.doc.stock_uom): + msgprint(_("Please Update Stock UOM with the help of Stock UOM Replace Utility."), + raise_exception=1) def validate_conversion_factor(self): check_list = [] @@ -154,13 +155,14 @@ class DocType(DocListController): def validate_barcode(self): if self.doc.barcode: - duplicate = webnotes.conn.sql("select name from tabItem where barcode = %s and name != %s", (self.doc.barcode, self.doc.name)) + duplicate = webnotes.conn.sql("""select name from tabItem where barcode = %s + and name != %s""", (self.doc.barcode, self.doc.name)) if duplicate: msgprint("Barcode: %s already used in item: %s" % (self.doc.barcode, cstr(duplicate[0][0])), raise_exception = 1) def check_non_asset_warehouse(self): - if self.doc.is_asset_item == "Yes": + if not self.doc.__islocal and self.doc.is_asset_item == "Yes": existing_qty = webnotes.conn.sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name) for e in existing_qty: msgprint("%s Units exist in Warehouse %s, which is not an Asset Warehouse." %