[fix] don't show expired items in website item list. Fixes #4210.

This commit is contained in:
Anand Doshi
2015-10-29 11:35:16 +05:30
parent 283b55f88c
commit 6d69ca6bac
4 changed files with 14 additions and 8 deletions

View File

@@ -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]