[fix] [minor] changed uom replace utility message
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index f5d50be..ac9f18f 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -30,8 +30,8 @@
self.check_warehouse_is_set_for_stock_item()
self.check_stock_uom_with_bin()
- self.validate_conversion_factor()
self.add_default_uom_in_conversion_factor_table()
+ self.validate_conversion_factor()
self.valiadte_item_type()
self.check_for_active_boms()
self.validate_price_lists()
@@ -59,15 +59,21 @@
ch = addchild(self.doc, 'uom_conversion_details', 'UOM Conversion Detail', self.doclist)
ch.uom = self.doc.stock_uom
ch.conversion_factor = 1
+
+ for d in self.doclist.get({"parentfield": "uom_conversion_details"}):
+ if d.conversion_factor == 1 and d.uom != self.doc.stock_uom:
+ self.doclist.remove(d)
+
def check_stock_uom_with_bin(self):
if not self.doc.fields.get("__islocal"):
bin_uom = webnotes.conn.get_value("Bin", {"item_code": self.doc.name}, "stock_uom")
if self.doc.stock_uom and bin_uom and cstr(bin_uom) != cstr(self.doc.stock_uom):
+ webnotes.errprint([self.doc.stock_uom, bin_uom])
webnotes.throw(_("Default Unit of Measure can not be changed directly \
- because you have already made some transaction(s) with another UOM. \
+ because you have already made some transaction(s) with another UOM.\n \
To change default UOM, use 'UOM Replace Utility' tool under Stock module."))
-
+
def validate_conversion_factor(self):
check_list = []
for d in getlist(self.doclist,'uom_conversion_details'):
diff --git a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
index 4e69a37..eff62f6 100644
--- a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
+++ b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
@@ -8,7 +8,7 @@
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes.model.code import get_obj
-from webnotes import msgprint
+from webnotes import msgprint, _
sql = webnotes.conn.sql
@@ -41,11 +41,11 @@
raise Exception
def update_item_master(self):
- # update stock uom in item master
- sql("update `tabItem` set stock_uom = '%s' where name = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
+ item_bean = webnotes.bean("Item", self.doc.item_code)
+ item_bean.doc.stock_uom = self.doc.new_stock_uom
+ item_bean.save()
- # acknowledge user
- msgprint("New Stock UOM : " + cstr(self.doc.new_stock_uom) + " updated in Item : " + cstr(self.doc.item_code))
+ msgprint(_("Default UOM updated in item ") + self.doc.item_code)
def update_bin(self):
# update bin
@@ -80,20 +80,14 @@
# Update Stock UOM
def update_stock_uom(self):
- # validate mandatory
self.validate_mandatory()
self.validate_uom_integer_type()
- # update item master
self.update_item_master()
- # update stock ledger entry
self.update_stock_ledger_entry()
- # update bin
self.update_bin()
-
- get_obj("Item", self.doc.item_code).on_update()
def validate_uom_integer_type(self):
current_is_integer = webnotes.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number")