From 9d44ac88f2a4181db268a25c5a4c22a3ed073c48 Mon Sep 17 00:00:00 2001 From: gabtzi Date: Mon, 28 Dec 2015 10:26:42 +0200 Subject: [PATCH] Fix for Issue #4543: Automatic item_code generation for variants when parent item is named after a Naming Series --- erpnext/stock/doctype/item/item.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index dfe17e89fc0..12c39dbdc3d 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -33,6 +33,11 @@ class Item(WebsiteGenerator): if frappe.db.get_default("item_naming_by")=="Naming Series" and not self.variant_of: from frappe.model.naming import make_autoname self.item_code = make_autoname(self.naming_series+'.#####') + elif frappe.db.get_default("item_naming_by")=="Naming Series" and self.variant_of: + item_code_suffix = "" + for attribute in self.attributes: + item_code_suffix += "-" + str(attribute.attribute_value) + self.item_code = str(self.variant_of) + item_code_suffix elif not self.item_code: msgprint(_("Item Code is mandatory because Item is not automatically numbered"), raise_exception=1)