mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
[fix] item.py fix for _doc_before_save
This commit is contained in:
@@ -58,9 +58,6 @@ class Item(WebsiteGenerator):
|
|||||||
if self.is_sales_item and not self.get('is_item_from_hub'):
|
if self.is_sales_item and not self.get('is_item_from_hub'):
|
||||||
self.publish_in_hub = 1
|
self.publish_in_hub = 1
|
||||||
|
|
||||||
def before_save(self):
|
|
||||||
self.get_doc_before_save()
|
|
||||||
|
|
||||||
def after_insert(self):
|
def after_insert(self):
|
||||||
'''set opening stock and item price'''
|
'''set opening stock and item price'''
|
||||||
if self.standard_rate:
|
if self.standard_rate:
|
||||||
@@ -70,9 +67,7 @@ class Item(WebsiteGenerator):
|
|||||||
self.set_opening_stock()
|
self.set_opening_stock()
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.before_update = None
|
self.get_doc_before_save()
|
||||||
if frappe.db.exists('Item', self.name):
|
|
||||||
self.before_update = frappe.get_doc('Item', self.name)
|
|
||||||
|
|
||||||
super(Item, self).validate()
|
super(Item, self).validate()
|
||||||
|
|
||||||
@@ -638,8 +633,9 @@ class Item(WebsiteGenerator):
|
|||||||
|
|
||||||
def validate_stock_exists_for_template_item(self):
|
def validate_stock_exists_for_template_item(self):
|
||||||
if self.stock_ledger_created():
|
if self.stock_ledger_created():
|
||||||
if (self._doc_before_save.has_variants != self.has_variants or
|
if ((self._doc._doc_before_save
|
||||||
self.variant_of != self._doc_before_save.variant_of):
|
and self._doc_before_save.has_variants != self.has_variants)
|
||||||
|
or self.variant_of != self._doc_before_save.variant_of):
|
||||||
frappe.throw(_("Cannot change Variant properties after stock transction. You will have to make a new Item to do this.").format(self.name),
|
frappe.throw(_("Cannot change Variant properties after stock transction. You will have to make a new Item to do this.").format(self.name),
|
||||||
StockExistsForTemplate)
|
StockExistsForTemplate)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user