Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Cannot create Item Variants Version 13

With the latest release of version 13. I am not able to create variants from item template. Apparently when we click create variant and enter the attributes value. It does not copy the attributes value to the new item creation.
Any ones else facing the same issue?

please provide installed frappe , erpnext app version, and also the error message screenshot.

ERPNext: v13.1.0 (version-13)
Frappe Framework: v13.1.2 (version-13)



Attribute Values not being added

Traceback (most recent call last):
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/app.py", line 67, in application
    response = frappe.api.handle()
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/api.py", line 58, in handle
    return frappe.handler.handle()
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/handler.py", line 32, in handle
    data = execute_cmd(cmd)
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/handler.py", line 68, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/__init__.py", line 1166, in call
    return fn(*args, **newargs)
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/model/document.py", line 284, in save
    return self._save(*args, **kwargs)
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/model/document.py", line 306, in _save
    self.insert()
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/model/document.py", line 232, in insert
    self.set_new_name(set_name=set_name, set_child_names=set_child_names)
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/model/document.py", line 422, in set_new_name
    set_new_name(self)
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/model/naming.py", line 55, in set_new_name
    frappe.throw(_("{0} is required").format(doc.meta.get_label(fieldname)))
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/__init__.py", line 424, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/__init__.py", line 403, in msgprint
    _raise_exception()
  File "/Users/ahmad/frappe/bench-13/apps/frappe/frappe/__init__.py", line 357, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Item Code is required

refer to this github issue https://github.com/frappe/erpnext/issues/25037

this is caused by incorrectly added attribute field into the item variant setting fields list.
related code is at erpnext.controllers.item_variant.copy_attribute_to_variant
allow_fields = [d.field_name for d in frappe.get_all(“Variant Field”, fields = [‘field_name’])]

solution:
make sure both 2 fields: attribute and has_variants not among the fields list.

2 Likes

Thanks. Deleting these fields resolved the issue.

I also suggest to add it in the code to make it fail safe. In the exclude_fields

2 Likes