diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 97367013d7..bc2d48f4b2 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe import urllib +from frappe.utils import nowdate from frappe.utils.nestedset import NestedSet from frappe.website.website_generator import WebsiteGenerator from frappe.website.render import clear_cache @@ -71,14 +72,15 @@ def get_product_list_for_group(product_group=None, start=0, limit=10): concat(parent_website_route, "/", page_name) as route from `tabItem` where show_in_website = 1 + and (end_of_life is null or end_of_life='0000-00-00' or end_of_life > %(today)s) and (variant_of = '' or variant_of is null) - and (item_group in (%s) - or name in (select parent from `tabWebsite Item Group` where item_group in (%s))) - """ % (child_groups, child_groups) + and (item_group in ({child_groups}) + or name in (select parent from `tabWebsite Item Group` where item_group in ({child_groups}))) + """.format(child_groups=child_groups) query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit) - data = frappe.db.sql(query, {"product_group": product_group}, as_dict=1) + data = frappe.db.sql(query, {"product_group": product_group, "today": nowdate()}, as_dict=1) return [get_item_for_list_in_html(r) for r in data] diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index c62195767b..db7b50ae9c 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -245,7 +245,7 @@ class Item(WebsiteGenerator): # loop through previous attributes for prev_attr in self.attributes[:i]: - combination_source.append([context.selected_attributes[prev_attr.attribute]]) + combination_source.append([context.selected_attributes.get(prev_attr.attribute)]) combination_source.append(context.attribute_values[attr.attribute]) diff --git a/erpnext/templates/generators/item.html b/erpnext/templates/generators/item.html index acbcedfd82..500a11853e 100644 --- a/erpnext/templates/generators/item.html +++ b/erpnext/templates/generators/item.html @@ -24,7 +24,7 @@ {{ web_long_description or description or _("No description given") }}
- {{ _("Item Code") }}: {{ name }}
+ {{ _("Item Code") }}: {{ variant and variant.name or name }}