[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 from __future__ import unicode_literals
import frappe import frappe
import urllib import urllib
from frappe.utils import nowdate
from frappe.utils.nestedset import NestedSet from frappe.utils.nestedset import NestedSet
from frappe.website.website_generator import WebsiteGenerator from frappe.website.website_generator import WebsiteGenerator
from frappe.website.render import clear_cache 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 concat(parent_website_route, "/", page_name) as route
from `tabItem` from `tabItem`
where show_in_website = 1 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 (variant_of = '' or variant_of is null)
and (item_group in (%s) and (item_group in ({child_groups})
or name in (select parent from `tabWebsite Item Group` where item_group in (%s))) or name in (select parent from `tabWebsite Item Group` where item_group in ({child_groups})))
""" % (child_groups, child_groups) """.format(child_groups=child_groups)
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit) 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] return [get_item_for_list_in_html(r) for r in data]

View File

@ -245,7 +245,7 @@ class Item(WebsiteGenerator):
# loop through previous attributes # loop through previous attributes
for prev_attr in self.attributes[:i]: 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]) combination_source.append(context.attribute_values[attr.attribute])

View File

@ -24,7 +24,7 @@
{{ web_long_description or description or _("No description given") }} {{ web_long_description or description or _("No description given") }}
</div> </div>
<p class="text-muted"> <p class="text-muted">
{{ _("Item Code") }}: <span itemprop="productID">{{ name }}</span></p> {{ _("Item Code") }}: <span itemprop="productID">{{ variant and variant.name or name }}</span></p>
<br> <br>
<div class="item-attribute-selectors"> <div class="item-attribute-selectors">
{% if has_variants %} {% if has_variants %}

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr from frappe.utils import cstr, nowdate
from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_html from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_html
no_cache = 1 no_cache = 1
@ -14,7 +14,10 @@ def get_product_list(search=None, start=0, limit=10):
# base query # base query
query = """select name, item_name, page_name, website_image, thumbnail, item_group, query = """select name, item_name, page_name, website_image, thumbnail, item_group,
web_long_description as website_description, parent_website_route web_long_description as website_description, parent_website_route
from `tabItem` where show_in_website = 1 and (variant_of is null or variant_of = '')""" 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 is null or variant_of = '')"""
# search term condition # search term condition
if search: if search:
@ -29,6 +32,7 @@ def get_product_list(search=None, start=0, limit=10):
data = frappe.db.sql(query, { data = frappe.db.sql(query, {
"search": search, "search": search,
"today": nowdate()
}, as_dict=1) }, as_dict=1)
for d in data: for d in data: