fix(item_defaults): handle multiple item defaults for a company (#15634)

This commit is contained in:
Alchez 2018-10-11 16:56:46 +05:30 committed by Nabin Hait
parent 64b6421fce
commit a16f0f4423

View File

@ -122,6 +122,7 @@ class Item(WebsiteGenerator):
self.validate_fixed_asset()
self.validate_retain_sample()
self.validate_uom_conversion_factor()
self.validate_item_defaults()
self.update_defaults_from_item_group()
if not self.get("__islocal"):
@ -663,6 +664,12 @@ class Item(WebsiteGenerator):
template_item.flags.ignore_permissions = True
template_item.save()
def validate_item_defaults(self):
companies = list(set([row.company for row in self.item_defaults]))
if len(companies) != len(self.item_defaults):
frappe.throw(_("Cannot set multiple Item Defaults for a company."))
def update_defaults_from_item_group(self):
"""Get defaults from Item Group"""
if self.item_group and not self.item_defaults: