mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
fix: can not create item variants (#25433)
* fix: item_code assigned to function returning None * fix: ignore has_variants and attributes in variant * fix: patch to remove has_variants and attributes * chore: fix whitespace in translation
This commit is contained in:
@@ -262,7 +262,8 @@ def copy_attributes_to_variant(item, variant):
|
|||||||
# copy non no-copy fields
|
# copy non no-copy fields
|
||||||
|
|
||||||
exclude_fields = ["naming_series", "item_code", "item_name", "show_in_website",
|
exclude_fields = ["naming_series", "item_code", "item_name", "show_in_website",
|
||||||
"show_variant_in_website", "opening_stock", "variant_of", "valuation_rate"]
|
"show_variant_in_website", "opening_stock", "variant_of", "valuation_rate",
|
||||||
|
"has_variants", "attributes"]
|
||||||
|
|
||||||
if item.variant_based_on=='Manufacturer':
|
if item.variant_based_on=='Manufacturer':
|
||||||
# don't copy manufacturer values if based on part no
|
# don't copy manufacturer values if based on part no
|
||||||
|
|||||||
@@ -773,3 +773,4 @@ erpnext.patches.v13_0.fix_non_unique_represents_company
|
|||||||
erpnext.patches.v12_0.add_document_type_field_for_italy_einvoicing
|
erpnext.patches.v12_0.add_document_type_field_for_italy_einvoicing
|
||||||
erpnext.patches.v13_0.make_non_standard_user_type #13-04-2021
|
erpnext.patches.v13_0.make_non_standard_user_type #13-04-2021
|
||||||
erpnext.patches.v13_0.update_shipment_status
|
erpnext.patches.v13_0.update_shipment_status
|
||||||
|
erpnext.patches.v13_0.remove_attribute_field_from_item_variant_setting
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
"""Remove has_variants and attribute fields from item variant settings."""
|
||||||
|
frappe.reload_doc("stock", "doctype", "Item Variant Settings")
|
||||||
|
|
||||||
|
frappe.db.sql("""delete from `tabVariant Field`
|
||||||
|
where field_name in ('attributes', 'has_variants')""")
|
||||||
@@ -63,7 +63,7 @@ class Item(WebsiteGenerator):
|
|||||||
if self.variant_of:
|
if self.variant_of:
|
||||||
if not self.item_code:
|
if not self.item_code:
|
||||||
template_item_name = frappe.db.get_value("Item", self.variant_of, "item_name")
|
template_item_name = frappe.db.get_value("Item", self.variant_of, "item_name")
|
||||||
self.item_code = make_variant_item_code(self.variant_of, template_item_name, self)
|
make_variant_item_code(self.variant_of, template_item_name, self)
|
||||||
else:
|
else:
|
||||||
from frappe.model.naming import set_name_by_naming_series
|
from frappe.model.naming import set_name_by_naming_series
|
||||||
set_name_by_naming_series(self)
|
set_name_by_naming_series(self)
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ class ItemVariantSettings(Document):
|
|||||||
def set_default_fields(self):
|
def set_default_fields(self):
|
||||||
self.fields = []
|
self.fields = []
|
||||||
fields = frappe.get_meta('Item').fields
|
fields = frappe.get_meta('Item').fields
|
||||||
exclude_fields = ["naming_series", "item_code", "item_name", "show_in_website",
|
exclude_fields = {"naming_series", "item_code", "item_name", "show_in_website",
|
||||||
"show_variant_in_website", "standard_rate", "opening_stock", "image", "description",
|
"show_variant_in_website", "standard_rate", "opening_stock", "image", "description",
|
||||||
"variant_of", "valuation_rate", "description", "barcodes",
|
"variant_of", "valuation_rate", "description", "barcodes",
|
||||||
"website_image", "thumbnail", "website_specifiations", "web_long_description"]
|
"website_image", "thumbnail", "website_specifiations", "web_long_description",
|
||||||
|
"has_variants", "attributes"}
|
||||||
|
|
||||||
for d in fields:
|
for d in fields:
|
||||||
if not d.no_copy and d.fieldname not in exclude_fields and \
|
if not d.no_copy and d.fieldname not in exclude_fields and \
|
||||||
|
|||||||
Reference in New Issue
Block a user