From b9b49632f2ec4c006bd1ef99877b789ed6646de0 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 6 Aug 2015 13:35:12 +0530 Subject: [PATCH] Added patch to fetch Item Template Attributes --- erpnext/patches.txt | 1 + erpnext/patches/v5_4/item_template.py | 16 ++++++++++++++++ erpnext/stock/doctype/item/item_list.js | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v5_4/item_template.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 8e3aab1d978..c7c938832bc 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -192,3 +192,4 @@ erpnext.patches.v5_4.fix_missing_item_images erpnext.patches.v5_4.stock_entry_additional_costs erpnext.patches.v5_4.cleanup_journal_entry execute:frappe.db.sql("update `tabProduction Order` pro set description = (select description from tabItem where name=pro.production_item) where ifnull(description, '') = ''") +erpnext.patches.v5_4.item_template diff --git a/erpnext/patches/v5_4/item_template.py b/erpnext/patches/v5_4/item_template.py new file mode 100644 index 00000000000..4183654d16f --- /dev/null +++ b/erpnext/patches/v5_4/item_template.py @@ -0,0 +1,16 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + item_attribute = {} + for d in frappe.db.sql("""select DISTINCT va.attribute, i.variant_of from `tabVariant Attribute` va, `tabItem` i \ + where va.parent = i.name""", as_dict=1): + item_attribute.setdefault(d.variant_of, []).append({"attribute": d.attribute}) + + for item, attributes in item_attribute.items(): + template = frappe.get_doc("Item", item) + template.set('valid_attributes', attributes) + template.save() \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item_list.js b/erpnext/stock/doctype/item/item_list.js index 6eaa4920ea8..46a22ea5d56 100644 --- a/erpnext/stock/doctype/item/item_list.js +++ b/erpnext/stock/doctype/item/item_list.js @@ -6,7 +6,7 @@ frappe.listview_settings['Item'] = { if(doc.end_of_life && doc.end_of_life < frappe.datetime.get_today()) { return [__("Expired"), "grey", "end_of_life,<,Today"] } else if(doc.has_variants) { - return [__("Template"), "blue", "has_variant,=,1"] + return [__("Template"), "blue", "has_variants,=,Yes"] } else if(doc.variant_of) { return [__("Variant"), "green", "variant_of,=," + doc.variant_of] } else {