Merge branch 'develop' of https://github.com/frappe/erpnext into purchase-invoice-fix

This commit is contained in:
Neil Trini Lasrado 2014-08-20 14:57:24 +05:30
commit b02b59b8c8
10 changed files with 777 additions and 786 deletions

View File

@ -65,9 +65,11 @@ class StatusUpdater(Document):
self.validate_qty()
def set_status(self, update=False):
if self.get("__islocal"):
if self.is_new():
return
_status = self.status
if self.doctype in status_map:
sl = status_map[self.doctype][:]
sl.reverse()
@ -83,9 +85,11 @@ class StatusUpdater(Document):
self.status = s[0]
break
if self.status != _status:
self.add_comment("Label", self.status)
if update:
frappe.db.set_value(self.doctype, self.name, "status", self.status)
self.add_comment("Label", self.status)
def on_communication(self):
if not self.get("communications"): return

View File

@ -18,7 +18,7 @@
<span class="label label-warning filterable"
data-filter="per_delivered,<,100|status,!=,Stopped"
title="{%= __("Pending") %}">
{%= doc.get_formatted("delivery_date")%}</span>
{%= doc.get_formatted("delivery_date") || "Pending" %}</span>
{% } %}
{% } %}
{% if(doc.per_delivered == 100 && doc.status!=="Stopped") { %}

View File

@ -83,10 +83,11 @@
{
"depends_on": "show_in_website",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"label": "Parent Website Page",
"options": "Website Route",
"permlevel": 0
"fieldtype": "Read Only",
"label": "Parent Website Route",
"options": "",
"permlevel": 0,
"read_only": 1
},
{
"depends_on": "show_in_website",
@ -163,7 +164,7 @@
"in_create": 1,
"issingle": 0,
"max_attachments": 3,
"modified": "2014-06-10 05:37:03.763185",
"modified": "2014-08-19 06:42:03.262273",
"modified_by": "Administrator",
"module": "Setup",
"name": "Item Group",

View File

@ -9,22 +9,16 @@ from frappe.website.website_generator import WebsiteGenerator
from frappe.website.render import clear_cache
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
condition_field = "show_in_website"
template = "templates/generators/item_group.html"
class ItemGroup(NestedSet, WebsiteGenerator):
nsm_parent_field = 'parent_item_group'
condition_field = "show_in_website"
template = "templates/generators/item_group.html"
parent_website_route_field = "parent_item_group"
def autoname(self):
self.name = self.item_group_name
def validate(self):
WebsiteGenerator.validate(self)
if not self.parent_website_route:
if frappe.db.get_value("Item Group", self.parent_item_group, "show_in_website"):
self.parent_website_route = frappe.get_website_route("Item Group",
self.parent_item_group)
def on_update(self):
NestedSet.on_update(self)
WebsiteGenerator.on_update(self)
@ -60,14 +54,16 @@ def get_product_list_for_group(product_group=None, start=0, limit=10):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
# base query
query = """select t1.name, t1.item_name, t1.page_name, t1.website_image, t1.item_group,
t1.web_long_description as website_description, t2.name as route
from `tabItem` t1, `tabWebsite Route` t2
where t1.show_in_website = 1 and (item_group in (%s)
or t1.name in (select parent from `tabWebsite Item Group` where item_group in (%s)))
and t1.name = t2.docname and t2.ref_doctype='Item' """ % (child_groups, child_groups)
query = """select name, item_name, page_name, website_image, item_group,
web_long_description as website_description,
concat(parent_website_route, "/", page_name) as route
from `tabItem`
where show_in_website = 1
and (item_group in (%s)
or name in (select parent from `tabWebsite Item Group` where item_group in (%s)))
""" % (child_groups, child_groups)
query += """order by t1.weightage desc, t1.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)
@ -107,6 +103,6 @@ def invalidate_cache_for(doc, item_group=None):
item_group = doc.name
for i in get_parent_item_groups(item_group):
route = frappe.db.get_value("Website Route", {"ref_doctype":"Item Group", "docname": i.name})
route = doc.get_route()
if route:
clear_cache(route)

View File

@ -190,16 +190,16 @@
{
"default": "partners",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"fieldtype": "Read Only",
"label": "Parent Website Route",
"options": "Website Route",
"options": "",
"permlevel": 0
}
],
"icon": "icon-user",
"idx": 1,
"in_create": 0,
"modified": "2014-06-27 09:21:33.687012",
"modified": "2014-08-19 06:42:33.103060",
"modified_by": "Administrator",
"module": "Setup",
"name": "Sales Partner",

View File

@ -6,14 +6,15 @@ import frappe
from frappe.utils import cstr, filter_strip_join
from frappe.website.website_generator import WebsiteGenerator
condition_field = "show_in_website"
template = "templates/generators/sales_partner.html"
class SalesPartner(WebsiteGenerator):
page_title_field = "partner_name"
condition_field = "show_in_website"
template = "templates/generators/sales_partner.html"
def autoname(self):
self.name = self.partner_name
def validate(self):
self.parent_website_route = "partners"
super(SalesPartner, self).validate()
if self.partner_website and not self.partner_website.startswith("http"):
self.partner_website = "http://" + self.partner_website
@ -27,9 +28,6 @@ class SalesPartner(WebsiteGenerator):
else:
return ''
def get_page_title(self):
return self.partner_name
def get_context(self, context):
address = frappe.db.get_value("Address",
{"sales_partner": self.name, "is_primary_address": 1},
@ -46,7 +44,3 @@ class SalesPartner(WebsiteGenerator):
})
return context
def get_parent_website_route(self):
parent_website_sitemap = super(SalesPartner, self).get_parent_website_route()
return parent_website_sitemap or "partners"

View File

@ -59,7 +59,7 @@ class website_maker(object):
website_settings.append("top_bar_items", {
"doctype": "Top Bar Item",
"label": _("Products"),
"url": frappe.db.get_value("Website Route", {"ref_doctype":"Item Group"})
"url": "products"
})
website_settings.save()

View File

@ -814,18 +814,18 @@
},
{
"fieldname": "parent_website_route",
"fieldtype": "Link",
"fieldtype": "Read Only",
"ignore_user_permissions": 1,
"label": "Parent Website Route",
"no_copy": 1,
"options": "Website Route",
"options": "",
"permlevel": 0
}
],
"icon": "icon-tag",
"idx": 1,
"max_attachments": 1,
"modified": "2014-08-18 09:32:57.268763",
"modified": "2014-08-19 06:41:28.565607",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",

View File

@ -12,10 +12,12 @@ from frappe.website.doctype.website_slideshow.website_slideshow import get_slide
class WarehouseNotSet(frappe.ValidationError): pass
condition_field = "show_in_website"
template = "templates/generators/item.html"
class Item(WebsiteGenerator):
page_title_field = "item_name"
condition_field = "show_in_website"
template = "templates/generators/item.html"
parent_website_route_field = "item_group"
def onload(self):
super(Item, self).onload()
self.get("__onload").sle_exists = self.check_if_sle_exists()
@ -49,9 +51,6 @@ class Item(WebsiteGenerator):
self.cant_change()
self.validate_item_type_for_reorder()
if not self.parent_website_route:
self.parent_website_route = frappe.get_website_route("Item Group", self.item_group)
if not self.get("__islocal"):
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
self.old_website_item_groups = frappe.db.sql_list("""select item_group from `tabWebsite Item Group`
@ -216,14 +215,6 @@ class Item(WebsiteGenerator):
item_description=%s, modified=NOW() where item_code=%s""",
(self.item_name, self.description, self.name))
def get_page_title(self):
if self.name==self.item_name:
page_name_from = self.name
else:
page_name_from = self.name + " - " + self.item_name
return page_name_from
def get_tax_rate(self, tax_type):
return { "tax_rate": frappe.db.get_value("Account", tax_type, "tax_rate") }

View File

@ -12,23 +12,28 @@ no_sitemap = 1
@frappe.whitelist(allow_guest=True)
def get_product_list(search=None, start=0, limit=10):
# base query
query = """select t1.name, t1.item_name, t1.page_name, t1.website_image, t1.item_group,
t1.web_long_description as website_description, t2.name as route
from `tabItem` t1, `tabWebsite Route` t2 where t1.show_in_website = 1
and t1.name = t2.docname and t2.ref_doctype = 'Item'"""
query = """select name, item_name, page_name, website_image, item_group,
web_long_description as website_description, parent_website_route
from `tabItem` where show_in_website = 1"""
# search term condition
if search:
query += """and (t1.web_long_description like %(search)s or t1.description like %(search)s or
t1.item_name like %(search)s or t1.name like %(search)s)"""
query += """and web_long_description like %(search)s
or description like %(search)s
or item_name like %(search)s
or name like %(search)s)"""
search = "%" + cstr(search) + "%"
# order by
query += """order by t1.weightage desc, t1.modified desc limit %s, %s""" % (start, limit)
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
data = frappe.db.sql(query, {
"search": search,
}, as_dict=1)
for d in data:
d.route = ((d.parent_website_route + "/") if d.parent_website_route else "") \
+ d.page_name
return [get_item_for_list_in_html(r) for r in data]