Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
83feeb1779
@ -30,8 +30,8 @@ class DocType(DocListController):
|
|||||||
|
|
||||||
self.check_warehouse_is_set_for_stock_item()
|
self.check_warehouse_is_set_for_stock_item()
|
||||||
self.check_stock_uom_with_bin()
|
self.check_stock_uom_with_bin()
|
||||||
self.validate_conversion_factor()
|
|
||||||
self.add_default_uom_in_conversion_factor_table()
|
self.add_default_uom_in_conversion_factor_table()
|
||||||
|
self.validate_conversion_factor()
|
||||||
self.valiadte_item_type()
|
self.valiadte_item_type()
|
||||||
self.check_for_active_boms()
|
self.check_for_active_boms()
|
||||||
self.validate_price_lists()
|
self.validate_price_lists()
|
||||||
@ -60,14 +60,19 @@ class DocType(DocListController):
|
|||||||
ch.uom = self.doc.stock_uom
|
ch.uom = self.doc.stock_uom
|
||||||
ch.conversion_factor = 1
|
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):
|
def check_stock_uom_with_bin(self):
|
||||||
if not self.doc.fields.get("__islocal"):
|
if not self.doc.fields.get("__islocal"):
|
||||||
bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s",
|
bin_uom = webnotes.conn.get_value("Bin", {"item_code": self.doc.name}, "stock_uom")
|
||||||
self.doc.name)
|
if self.doc.stock_uom and bin_uom and cstr(bin_uom) != cstr(self.doc.stock_uom):
|
||||||
if self.doc.stock_uom and bin and cstr(bin[0][0]) \
|
webnotes.errprint([self.doc.stock_uom, bin_uom])
|
||||||
and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
|
webnotes.throw(_("Default Unit of Measure can not be changed directly \
|
||||||
msgprint(_("Please Update Stock UOM with the help of Stock UOM Replace Utility."),
|
because you have already made some transaction(s) with another UOM.\n \
|
||||||
raise_exception=1)
|
To change default UOM, use 'UOM Replace Utility' tool under Stock module."))
|
||||||
|
|
||||||
def validate_conversion_factor(self):
|
def validate_conversion_factor(self):
|
||||||
check_list = []
|
check_list = []
|
||||||
|
@ -8,7 +8,7 @@ from webnotes.utils import cstr, flt, now, cint
|
|||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.bean import copy_doclist
|
from webnotes.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint, _
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
@ -41,11 +41,11 @@ class DocType:
|
|||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
def update_item_master(self):
|
def update_item_master(self):
|
||||||
# update stock uom in item master
|
item_bean = webnotes.bean("Item", self.doc.item_code)
|
||||||
sql("update `tabItem` set stock_uom = '%s' where name = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
item_bean.doc.stock_uom = self.doc.new_stock_uom
|
||||||
|
item_bean.save()
|
||||||
|
|
||||||
# acknowledge user
|
msgprint(_("Default UOM updated in item ") + self.doc.item_code)
|
||||||
msgprint("New Stock UOM : " + cstr(self.doc.new_stock_uom) + " updated in Item : " + cstr(self.doc.item_code))
|
|
||||||
|
|
||||||
def update_bin(self):
|
def update_bin(self):
|
||||||
# update bin
|
# update bin
|
||||||
@ -80,21 +80,15 @@ class DocType:
|
|||||||
|
|
||||||
# Update Stock UOM
|
# Update Stock UOM
|
||||||
def update_stock_uom(self):
|
def update_stock_uom(self):
|
||||||
# validate mandatory
|
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_uom_integer_type()
|
self.validate_uom_integer_type()
|
||||||
|
|
||||||
# update item master
|
|
||||||
self.update_item_master()
|
self.update_item_master()
|
||||||
|
|
||||||
# update stock ledger entry
|
|
||||||
self.update_stock_ledger_entry()
|
self.update_stock_ledger_entry()
|
||||||
|
|
||||||
# update bin
|
|
||||||
self.update_bin()
|
self.update_bin()
|
||||||
|
|
||||||
get_obj("Item", self.doc.item_code).on_update()
|
|
||||||
|
|
||||||
def validate_uom_integer_type(self):
|
def validate_uom_integer_type(self):
|
||||||
current_is_integer = webnotes.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number")
|
current_is_integer = webnotes.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number")
|
||||||
new_is_integer = webnotes.conn.get_value("UOM", self.doc.new_stock_uom, "must_be_whole_number")
|
new_is_integer = webnotes.conn.get_value("UOM", self.doc.new_stock_uom, "must_be_whole_number")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user