Don't update variant when template is updated (#8922)
* [fix] allow editing of variant properties, reverting earlier fix * [minor] dont automatically update variants when the template is saved
This commit is contained in:
parent
012c9a0916
commit
4bcc2316a9
@ -100,7 +100,6 @@ class Item(WebsiteGenerator):
|
||||
invalidate_cache_for_item(self)
|
||||
self.validate_name_with_item_group()
|
||||
self.update_item_price()
|
||||
self.update_variants()
|
||||
self.update_template_item()
|
||||
|
||||
def add_price(self, price_list=None):
|
||||
@ -612,23 +611,8 @@ class Item(WebsiteGenerator):
|
||||
if not template_item.show_in_website:
|
||||
template_item.show_in_website = 1
|
||||
template_item.flags.ignore_permissions = True
|
||||
template_item.flags.dont_update_variants = True
|
||||
template_item.save()
|
||||
|
||||
def update_variants(self):
|
||||
if self.flags.dont_update_variants:
|
||||
return
|
||||
if self.has_variants:
|
||||
updated = []
|
||||
variants = frappe.db.get_all("Item", fields=["item_code"], filters={"variant_of": self.name })
|
||||
for d in variants:
|
||||
variant = frappe.get_doc("Item", d)
|
||||
copy_attributes_to_variant(self, variant)
|
||||
variant.save()
|
||||
updated.append(d.item_code)
|
||||
if updated:
|
||||
frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
|
||||
|
||||
def validate_has_variants(self):
|
||||
if not self.has_variants and frappe.db.get_value("Item", self.name, "has_variants"):
|
||||
if frappe.db.exists("Item", {"variant_of": self.name}):
|
||||
|
Loading…
Reference in New Issue
Block a user