fix: check transactions for batch, serial check
This commit is contained in:
parent
9087efa5be
commit
cdd79e3c40
@ -118,7 +118,6 @@ class Item(WebsiteGenerator):
|
|||||||
|
|
||||||
self.validate_has_variants()
|
self.validate_has_variants()
|
||||||
self.validate_stock_exists_for_template_item()
|
self.validate_stock_exists_for_template_item()
|
||||||
self.validate_asset_exists_for_serialized_asset()
|
|
||||||
self.validate_attributes()
|
self.validate_attributes()
|
||||||
self.validate_variant_attributes()
|
self.validate_variant_attributes()
|
||||||
self.validate_website_image()
|
self.validate_website_image()
|
||||||
@ -128,6 +127,7 @@ class Item(WebsiteGenerator):
|
|||||||
self.validate_uom_conversion_factor()
|
self.validate_uom_conversion_factor()
|
||||||
self.validate_item_defaults()
|
self.validate_item_defaults()
|
||||||
self.validate_customer_provided_part()
|
self.validate_customer_provided_part()
|
||||||
|
self.validate_stock_for_has_batch_and_has_serial()
|
||||||
|
|
||||||
if not self.get("__islocal"):
|
if not self.get("__islocal"):
|
||||||
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
|
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
|
||||||
@ -759,12 +759,6 @@ class Item(WebsiteGenerator):
|
|||||||
frappe.throw(
|
frappe.throw(
|
||||||
_('Cannot change Attributes after stock transaction. Make a new Item and transfer stock to the new Item'))
|
_('Cannot change Attributes after stock transaction. Make a new Item and transfer stock to the new Item'))
|
||||||
|
|
||||||
def validate_asset_exists_for_serialized_asset(self):
|
|
||||||
if (not self.get("__islocal") and self.asset_exists() and
|
|
||||||
cint(self.has_serial_no) != cint(frappe.db.get_value('Item', self.name, 'has_serial_no'))):
|
|
||||||
frappe.throw(_("Asset is already exists against the item {0}, you cannot change the has serial no value")
|
|
||||||
.format(self.name))
|
|
||||||
|
|
||||||
def asset_exists(self):
|
def asset_exists(self):
|
||||||
if not hasattr(self, '_asset_created'):
|
if not hasattr(self, '_asset_created'):
|
||||||
self._asset_created = frappe.db.get_all("Asset",
|
self._asset_created = frappe.db.get_all("Asset",
|
||||||
@ -824,6 +818,11 @@ class Item(WebsiteGenerator):
|
|||||||
for d in self.attributes:
|
for d in self.attributes:
|
||||||
d.variant_of = self.variant_of
|
d.variant_of = self.variant_of
|
||||||
|
|
||||||
|
def validate_stock_for_has_batch_and_has_serial(self):
|
||||||
|
if self.stock_ledger_created():
|
||||||
|
for value in ["has_batch_no", "has_serial_no"]:
|
||||||
|
if frappe.db.get_value("Item", self.name, value) != self.get_value(value):
|
||||||
|
frappe.throw(_("Cannot change {0} as Stock Transaction for Item {1} exist.".format(value, self.name)))
|
||||||
|
|
||||||
def get_timeline_data(doctype, name):
|
def get_timeline_data(doctype, name):
|
||||||
'''returns timeline data based on stock ledger entry'''
|
'''returns timeline data based on stock ledger entry'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user