Merge pull request #7966 from rohitwaghchaure/item_variant_issue_for_nuermic
[Fix] Item variants broken when using naming series for items and vriants of numeric value
This commit is contained in:
commit
fd9b2467d6
@ -169,7 +169,7 @@ def make_variant_item_code(template_item_code, variant):
|
||||
item_attribute = frappe.db.sql("""select i.numeric_values, v.abbr
|
||||
from `tabItem Attribute` i left join `tabItem Attribute Value` v
|
||||
on (i.name=v.parent)
|
||||
where i.name=%(attribute)s and v.attribute_value=%(attribute_value)s""", {
|
||||
where i.name=%(attribute)s and (v.attribute_value=%(attribute_value)s or i.numeric_values = 1)""", {
|
||||
"attribute": attr.attribute,
|
||||
"attribute_value": attr.attribute_value
|
||||
}, as_dict=True)
|
||||
@ -180,11 +180,8 @@ def make_variant_item_code(template_item_code, variant):
|
||||
# frappe.bold(attr.attribute_value)), title=_('Invalid Attribute'),
|
||||
# exc=InvalidItemAttributeValueError)
|
||||
|
||||
if item_attribute[0].numeric_values:
|
||||
# don't generate item code if one of the attributes is numeric
|
||||
return
|
||||
|
||||
abbreviations.append(item_attribute[0].abbr)
|
||||
abbr_or_value = cstr(attr.attribute_value) if item_attribute[0].numeric_values else item_attribute[0].abbr
|
||||
abbreviations.append(abbr_or_value)
|
||||
|
||||
if abbreviations:
|
||||
variant.item_code = "{0}-{1}".format(template_item_code, "-".join(abbreviations))
|
||||
|
@ -68,7 +68,7 @@ frappe.ui.form.on("Item", {
|
||||
frm.set_intro(__("This Item is a Variant of {0} (Template). Attributes will be copied over from the template unless 'No Copy' is set", [frm.doc.variant_of]), true);
|
||||
}
|
||||
|
||||
if (frappe.defaults.get_default("item_naming_by")!="Naming Series") {
|
||||
if (frappe.defaults.get_default("item_naming_by")!="Naming Series" || frm.doc.variant_of) {
|
||||
frm.toggle_display("naming_series", false);
|
||||
} else {
|
||||
erpnext.toggle_naming_series();
|
||||
|
@ -162,14 +162,14 @@ class TestItem(unittest.TestCase):
|
||||
|
||||
variant = create_variant("_Test Numeric Template Item",
|
||||
{"Test Size": "Large", "Test Item Length": 1.1})
|
||||
self.assertEquals(variant.item_code, None)
|
||||
self.assertEquals(variant.item_code, "_Test Numeric Template Item-L-1.1")
|
||||
variant.item_code = "_Test Numeric Variant-L-1.1"
|
||||
variant.item_name = "_Test Numeric Variant Large 1.1m"
|
||||
self.assertRaises(InvalidItemAttributeValueError, variant.save)
|
||||
|
||||
variant = create_variant("_Test Numeric Template Item",
|
||||
{"Test Size": "Large", "Test Item Length": 1.5})
|
||||
self.assertEquals(variant.item_code, None)
|
||||
self.assertEquals(variant.item_code, "_Test Numeric Template Item-L-1.5")
|
||||
variant.item_code = "_Test Numeric Variant-L-1.5"
|
||||
variant.item_name = "_Test Numeric Variant Large 1.5m"
|
||||
variant.save()
|
||||
|
Loading…
x
Reference in New Issue
Block a user