[fix] force stock_uom in item and stock ledger entry

This commit is contained in:
Rushabh Mehta 2015-08-03 16:13:33 +05:30
parent ba9dbb1b09
commit b16b9cd7a0
4 changed files with 19 additions and 13 deletions

View File

@ -11,6 +11,8 @@ from erpnext.utilities.transaction_base import TransactionBase
from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
from erpnext.controllers.sales_and_purchase_return import validate_return
force_item_fields = ("item_name", "item_group", "barcode", "brand", "stock_uom")
class CustomerFrozen(frappe.ValidationError): pass
class AccountsController(TransactionBase):
@ -142,7 +144,8 @@ class AccountsController(TransactionBase):
for fieldname, value in ret.items():
if item.meta.get_field(fieldname) and \
item.get(fieldname) is None and value is not None:
(item.get(fieldname) is None or fieldname in force_item_fields) \
and value is not None:
item.set(fieldname, value)
if fieldname == "cost_center" and item.meta.get_field("cost_center") \

View File

@ -234,7 +234,7 @@ class StockController(AccountsController):
if d['reserved_qty'] < 0 :
# Reduce reserved qty from reserved warehouse mentioned in so
if not d["reserved_warehouse"]:
frappe.throw(_("Reserved Warehouse is missing in Sales Order"))
frappe.throw(_("Delivery Warehouse is missing in Sales Order"))
args = {
"item_code": d['item_code'],

View File

@ -108,9 +108,13 @@ class Item(WebsiteGenerator):
def check_stock_uom_with_bin(self):
if not self.get("__islocal"):
if self.stock_uom == frappe.db.get_value("Item", self.name, "stock_uom"):
return
matched=True
ref_uom = frappe.db.get_value("Stock Ledger Entry",
{"item_code": self.name}, "stock_uom")
if ref_uom:
if cstr(ref_uom) != cstr(self.stock_uom):
matched = False
@ -128,7 +132,7 @@ class Item(WebsiteGenerator):
(self.stock_uom, self.name))
if not matched:
frappe.throw(_("Default Unit of Measure can not be changed directly because you have already made some transaction(s) with another UOM. To change default UOM, use 'UOM Replace Utility' tool under Stock module."))
frappe.throw(_("Default Unit of Measure for Item {0} cannot be changed directly because you have already made some transaction(s) with another UOM. To change default UOM, use 'UOM Replace Utility' tool under Stock module.").format(self.name))
def update_template_tables(self):
template = frappe.get_doc("Item", self.variant_of)

View File

@ -82,7 +82,6 @@ class StockLedgerEntry(Document):
frappe.throw(_("Stock cannot exist for Item {0} since has variants").format(self.item_code),
ItemTemplateCannotHaveStock)
if not self.stock_uom:
self.stock_uom = item_det.stock_uom
def check_stock_frozen_date(self):