frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.78k stars 7.31k forks source link

Item code error while creating a multiples variants #25037

Closed SantiagoX9713 closed 3 years ago

SantiagoX9713 commented 3 years ago

Description of the issue

When trying to create new variants from a template and selecting the attributes of the new variants triggers the following error: Item Code is required

Context information (for bug reports)

erpnext 13.x.x-develop erpnext_telegram_integration 0.0.5 frappe 13.x.x-develop

Steps to reproduce the issue

  1. Create a new item that has variants mustn't be numeric values.
  2. Tap Create> Multiple Variants
  3. Choose at least two option

image

I'm using Ubuntu 18 & install with easy script

nabinhait commented 3 years ago

Can't replicate it, do you have any customization on your site?

szufisher commented 3 years ago

same issue on latest version-13 ERPNext: v13.0.1 (version-13)

Frappe Framework: v13.0.2 (version-13)

traceback as below Traceback (most recent call last): File "/home/fisher/erpnext/apps/frappe/frappe/app.py", line 67, in application response = frappe.api.handle() File "/home/fisher/erpnext/apps/frappe/frappe/api.py", line 58, in handle return frappe.handler.handle() File "/home/fisher/erpnext/apps/frappe/frappe/handler.py", line 30, in handle data = execute_cmd(cmd) File "/home/fisher/erpnext/apps/frappe/frappe/handler.py", line 70, in execute_cmd return frappe.call(method, frappe.form_dict) File "/home/fisher/erpnext/apps/frappe/frappe/init.py", line 1145, in call return fn(*args, *newargs) File "/home/fisher/erpnext/apps/erpnext/erpnext/controllers/item_variant.py", line 189, in enqueue_multiple_variant_creation return create_multiple_variants(item, args) File "/home/fisher/erpnext/apps/erpnext/erpnext/controllers/item_variant.py", line 205, in create_multiple_variants variant.save() File "/home/fisher/erpnext/apps/frappe/frappe/model/document.py", line 284, in save return self._save(args, kwargs) File "/home/fisher/erpnext/apps/frappe/frappe/model/document.py", line 306, in _save self.insert() File "/home/fisher/erpnext/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 "/home/fisher/erpnext/apps/frappe/frappe/model/document.py", line 422, in set_new_name set_new_name(self) File "/home/fisher/erpnext/apps/frappe/frappe/model/naming.py", line 55, in set_newname frappe.throw(("{0} is required").format(doc.meta.get_label(fieldname))) File "/home/fisher/erpnext/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 "/home/fisher/erpnext/apps/frappe/frappe/init.py", line 403, in msgprint _raise_exception() File "/home/fisher/erpnext/apps/frappe/frappe/init.py", line 357, in _raise_exception raise raise_exception(msg) frappe.exceptions.ValidationError: Item Code is required

rubberfashion commented 3 years ago

same issue on latest version-13 ERPNext: v13.0.1 (version-13) Frappe Framework: v13.0.2 (version-13) no custimization

I have the same issue with multiple variants. Clicking on "Make" cause the error.

Screenshot 2021-04-13 105117

Error:

Screenshot 2021-04-13 105156

That indicate maybe an error with autogenerating the item code.

Also, when i create a Single variant, select colour: black, size: S

Screenshot 2021-04-13 105302

fill out the "Item Code" and save

Screenshot 2021-04-13 105349

I can not specify any attribute value:

Screenshot 2021-04-13 104603 Screenshot 2021-04-13 104800

In the template file i can specify:

Screenshot 2021-04-13 110909 Screenshot 2021-04-13 110828
szufisher commented 3 years ago

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 attribute and has_variants 2 fields not among the fields list. image

seems patch to delete the attribute field is needed.

rubberfashion commented 3 years ago

Hi, Thank you for reply!! It works! Now the issue is gone. I deleted the "attribute" field and want to recreate it. I got a empty selection (when i am on page2 - page 1 is working) page 1:

Screenshot 2021-04-14 110131

page 2:

Screenshot 2021-04-14 110218

When i want to insert new row field list is empty:

Screenshot 2021-04-14 104240

I run the instance on a docker container EDGE version 13.x.x.x develop and Traefik.

szufisher commented 3 years ago

not understand what is the current problem, you can not add other fields into the field list in item variant setting screen? the 2 fields: attribute and has_variants should not be added back into this list as they are not needed to be copied from template item to variant item.

rubberfashion commented 3 years ago

Hi,

Thanks for your help. If i have further issues i will open a new thread.

:)