[Fixes] Warehouse check while company delete & Variant Attribute value check
This commit is contained in:
parent
c19afa140d
commit
5fe0086d9a
@ -61,7 +61,7 @@ def validate_item_variant_attributes(item, args):
|
||||
frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3}")\
|
||||
.format(attribute, from_range, to_range, increment), InvalidItemAttributeValueError)
|
||||
|
||||
elif value not in attribute_values[attribute]:
|
||||
elif value not in attribute_values.get(attribute, []):
|
||||
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values").format(
|
||||
value, attribute))
|
||||
|
||||
|
@ -207,12 +207,14 @@ class Company(Document):
|
||||
frappe.defaults.clear_default("company", value=self.name)
|
||||
|
||||
# clear default accounts, warehouses from item
|
||||
for f in ["default_warehouse", "website_warehouse"]:
|
||||
frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
|
||||
% (f, f, ', '.join(['%s']*len(warehouses))), tuple(warehouses))
|
||||
if warehouses:
|
||||
|
||||
frappe.db.sql("""delete from `tabItem Reorder` where warehouse in (%s)"""
|
||||
% ', '.join(['%s']*len(warehouses)), tuple(warehouses))
|
||||
for f in ["default_warehouse", "website_warehouse"]:
|
||||
frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
|
||||
% (f, f, ', '.join(['%s']*len(warehouses))), tuple(warehouses))
|
||||
|
||||
frappe.db.sql("""delete from `tabItem Reorder` where warehouse in (%s)"""
|
||||
% ', '.join(['%s']*len(warehouses)), tuple(warehouses))
|
||||
|
||||
for f in ["income_account", "expense_account"]:
|
||||
frappe.db.sql("""update tabItem set %s=NULL where %s in (%s)"""
|
||||
|
@ -341,10 +341,10 @@ class Item(WebsiteGenerator):
|
||||
frappe.throw(_("Please specify Attribute Value for attribute {0}").format(d.attribute))
|
||||
args[d.attribute] = d.attribute_value
|
||||
|
||||
if self.get("__islocal"):
|
||||
if self.variant_of:
|
||||
# test this during insert because naming is based on item_code and we cannot use condition like self.name != variant
|
||||
variant = get_variant(self.variant_of, args)
|
||||
if variant:
|
||||
if variant and self.get("__islocal"):
|
||||
frappe.throw(_("Item variant {0} exists with same attributes").format(variant), ItemVariantExistsError)
|
||||
|
||||
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
|
||||
|
Loading…
x
Reference in New Issue
Block a user