Merge pull request #1865 from frappe/wip-4.1

Wip 4.1
This commit is contained in:
Anand Doshi 2014-06-30 12:00:55 +05:30
commit c459fe21f8
25 changed files with 984 additions and 920 deletions

View File

@ -288,6 +288,7 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"create": 1,
"delete": 1,
"email": 1,

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe, os, json
def import_charts():
print "Importing Chart of Accounts"
frappe.db.sql("""delete from `tabChart of Accounts`""")
charts_dir = os.path.join(os.path.dirname(__file__), "charts")
for fname in os.listdir(charts_dir):
@ -19,8 +20,8 @@ def import_charts():
"source_file": fname,
"country": country
}).insert()
print doc.name.encode("utf-8")
else:
print "No chart for: " + chart.get("name").encode("utf-8")
frappe.db.commit()
#print doc.name.encode("utf-8")
#else:
#print "No chart for: " + chart.get("name").encode("utf-8")
frappe.db.commit()

View File

@ -0,0 +1,39 @@
<h2 class="text-center">{%= __("Statement of Account") %}</h2>
<h4 class="text-center">{%= filters.account || "General Ledger" %}</h3>
<hr>
<table class="table table-bordered">
<thead>
<tr>
<th style="width: 10%">{%= __("Date") %}</th>
<th style="width: 15%">{%= __("Ref") %}</th>
<th style="width: 45%">{%= __("Party") %}</th>
<th style="width: 15%">{%= __("Debit") %}</th>
<th style="width: 15%">{%= __("Credit") %}</th>
</tr>
</thead>
<tbody>
{% for(var i=0, l=data.length; i<l; i++) { %}
<tr>
{% if(data[i].posting_date) { %}
<td>{%= dateutil.str_to_user(data[i].posting_date) %}</td>
<td>{%= data[i].voucher_type%}
<br>{%= data[i].voucher_no %}</td>
<td>{%= data[i].account %}
<br>{%= __("Against") %}: {%= data[i].account %}
<br>{%= __("Remarks") %}: {%= data[i].remarks %}</td>
<td style="text-align: right">{%= format_currency(data[i].debit) %}</td>
<td style="text-align: right">{%= format_currency(data[i].credit) %}</td>
{% } else { %}
<td></td>
<td></td>
<td><b>{%= data[i].account || "&nbsp;" %}</b></td>
<td style="text-align: right">
{%= data[i].account && format_currency(data[i].debit) %}</td>
<td style="text-align: right">
{%= data[i].account && format_currency(data[i].credit) %}</td>
{% } %}
</tr>
{% } %}
</tbody>
</table>
<p class="text-right text-muted">Printed On {%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}</p>

View File

@ -91,6 +91,11 @@ def get_data():
"description": _("Manage Territory Tree."),
"doctype": "Territory",
},
{
"type": "doctype",
"name": "Sales Partner",
"description": _("Manage Sales Partners."),
},
{
"type": "page",
"label": _("Sales Person"),

View File

@ -19,11 +19,11 @@ notification_config = "erpnext.startup.notifications.get_notification_config"
dump_report_map = "erpnext.startup.report_data_map.data_map"
update_website_context = "erpnext.startup.webutils.update_website_context"
mail_footer = "erpnext.startup.mail_footer"
on_session_creation = "erpnext.startup.event_handlers.on_session_creation"
before_tests = "erpnext.setup.utils.before_tests"
website_generators = ["Item Group", "Item", "Sales Partner"]
standard_queries = "Customer:erpnext.selling.doctype.customer.customer.get_customer_list"
permission_query_conditions = {
@ -74,3 +74,4 @@ scheduler_events = {
"erpnext.setup.doctype.backup_manager.backup_manager.take_backups_weekly"
]
}

View File

@ -64,3 +64,4 @@ execute:frappe.db.sql("update `tabItem` set end_of_life=null where end_of_life='
erpnext.patches.v4_0.update_users_report_view_settings
erpnext.patches.v4_0.set_pricing_rule_for_buying_or_selling
erpnext.patches.v4_0.set_naming_series_property_setter
erpnext.patches.v4_1.set_outgoing_email_footer

View File

View File

@ -0,0 +1,11 @@
# 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
from erpnext.setup.install import default_mail_footer
def execute():
mail_footer = frappe.db.get_default('mail_footer') or ''
mail_footer += default_mail_footer
frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer)

View File

@ -64,6 +64,7 @@ class Customer(TransactionBase):
c.customer = self.name
c.customer_name = self.customer_name
c.is_primary_contact = 1
c.ignore_permissions = getattr(self, "ignore_permissions", None)
try:
c.save()
except frappe.NameError:

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,10 @@ import frappe
from frappe.utils.nestedset import NestedSet
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'
@ -39,6 +43,53 @@ class ItemGroup(NestedSet, WebsiteGenerator):
if frappe.db.exists("Item", self.name):
frappe.throw(frappe._("An item exists with same name ({0}), please change the item group name or rename the item").format(self.name))
def get_context(self, context):
context.update({
"items": get_product_list_for_group(product_group = self.name, limit=100),
"parent_groups": get_parent_item_groups(self.name),
"title": self.name
})
if self.slideshow:
context.update(get_slideshow(self))
return context
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 += """order by t1.weightage desc, t1.modified desc limit %s, %s""" % (start, limit)
data = frappe.db.sql(query, {"product_group": product_group}, as_dict=1)
return [get_item_for_list_in_html(r) for r in data]
def get_child_groups(item_group_name):
item_group = frappe.get_doc("Item Group", item_group_name)
return frappe.db.sql("""select name
from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s
and show_in_website = 1""", {"lft": item_group.lft, "rgt": item_group.rgt})
def get_item_for_list_in_html(context):
return frappe.get_template("templates/includes/product_in_grid.html").render(context)
def get_group_item_count(item_group):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
return frappe.db.sql("""select count(*) from `tabItem`
where docstatus = 0 and 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))[0][0]
def get_parent_item_groups(item_group_name):
item_group = frappe.get_doc("Item Group", item_group_name)
return frappe.db.sql("""select name, page_name from `tabItem Group`
@ -51,5 +102,6 @@ def invalidate_cache_for(doc, item_group=None):
item_group = doc.name
for i in get_parent_item_groups(item_group):
if i.page_name:
clear_cache(i.page_name)
route = frappe.db.get_value("Website Route", {"ref_doctype":"Item Group", "docname": i.name})
if route:
clear_cache(route)

View File

@ -17,6 +17,11 @@ cur_frm.cscript.refresh = function(doc,dt,dn){
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
cur_frm.cscript.make_contact(doc,dt,dn);
if (doc.show_in_website) {
cur_frm.set_intro(__("Published on website at: {0}",
[repl('<a href="/%(website_route)s" target="_blank">/%(website_route)s</a>', doc.__onload)]));
}
}
}

View File

@ -188,6 +188,7 @@
"permlevel": 0
},
{
"default": "partners",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"label": "Parent Website Route",
@ -198,7 +199,7 @@
"icon": "icon-user",
"idx": 1,
"in_create": 0,
"modified": "2014-05-27 03:49:18.661354",
"modified": "2014-06-27 09:21:33.687012",
"modified_by": "Administrator",
"module": "Setup",
"name": "Sales Partner",

View File

@ -3,9 +3,12 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cint, cstr, filter_strip_join
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):
def autoname(self):
self.name = self.partner_name
@ -25,3 +28,24 @@ class SalesPartner(WebsiteGenerator):
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},
"*", as_dict=True)
if address:
city_state = ", ".join(filter(None, [address.city, address.state]))
address_rows = [address.address_line1, address.address_line2,
city_state, address.pincode, address.country]
context.update({
"email": address.email_id,
"partner_address": filter_strip_join(address_rows, "\n<br>"),
"phone": filter_strip_join(cstr(address.phone).split(","), "\n<br>")
})
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

@ -7,6 +7,9 @@ import frappe
from frappe import _
default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
<a style="color: #888" href="http://erpnext.org">ERPNext</a></div>"""
def after_install():
frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
set_single_defaults()
@ -79,3 +82,6 @@ def set_single_defaults():
pass
frappe.db.set_default("date_format", "dd-mm-yyyy")
frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer",
default_mail_footer)

View File

@ -27,10 +27,6 @@ user_defaults = {
"Territory": "territory"
}
# add startup propertes
mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
<a style="color: #888" href="http://erpnext.org">ERPNext</a></div>"""
def get_monthly_bulk_mail_limit():
import frappe
# if global settings, then 500 or unlimited

View File

@ -6,11 +6,15 @@ import frappe
from frappe import msgprint, _
from frappe.utils import cstr, flt, getdate, now_datetime, formatdate
from frappe.website.website_generator import WebsiteGenerator
from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for
from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for, get_parent_item_groups
from frappe.website.render import clear_cache
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
class WarehouseNotSet(frappe.ValidationError): pass
condition_field = "show_in_website"
template = "templates/generators/item.html"
class Item(WebsiteGenerator):
def onload(self):
super(Item, self).onload()
@ -46,8 +50,10 @@ class Item(WebsiteGenerator):
if not self.parent_website_route:
self.parent_website_route = frappe.get_website_route("Item Group", self.item_group)
if self.name:
self.old_page_name = frappe.db.get_value('Item', self.name, 'page_name')
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`
where parentfield='website_item_groups' and parenttype='Item' and parent=%s""", self.name)
def on_update(self):
super(Item, self).on_update()
@ -55,6 +61,14 @@ class Item(WebsiteGenerator):
self.validate_name_with_item_group()
self.update_item_price()
def get_context(self, context):
context["parent_groups"] = get_parent_item_groups(self.item_group) + \
[{"name": self.name}]
if self.slideshow:
context.update(get_slideshow(self))
return context
def check_warehouse_is_set_for_stock_item(self):
if self.is_stock_item=="Yes" and not self.default_warehouse:
frappe.msgprint(_("Default Warehouse is mandatory for stock Item."),
@ -204,7 +218,7 @@ class Item(WebsiteGenerator):
if self.name==self.item_name:
page_name_from = self.name
else:
page_name_from = self.name + " " + self.item_name
page_name_from = self.name + " - " + self.item_name
return page_name_from
@ -351,6 +365,12 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
def invalidate_cache_for_item(doc):
invalidate_cache_for(doc, doc.item_group)
for d in doc.get({"doctype":"Website Item Group"}):
if d.item_group:
invalidate_cache_for(doc, d.item_group)
website_item_groups = list(set((doc.get("old_website_item_groups") or [])
+ [d.item_group for d in doc.get({"doctype":"Website Item Group"}) if d.item_group]))
for item_group in website_item_groups:
invalidate_cache_for(doc, item_group)
if doc.get("old_item_group"):
invalidate_cache_for(doc, doc.old_item_group)

View File

@ -1,20 +0,0 @@
# 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
from erpnext.setup.doctype.item_group.item_group import get_parent_item_groups
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
doctype = "Item"
condition_field = "show_in_website"
def get_context(context):
item_context = context.doc.as_dict()
item_context["parent_groups"] = get_parent_item_groups(context.doc.item_group) + \
[{"name":context.doc.name}]
if context.doc.slideshow:
item_context.update(get_slideshow(context.doc))
return item_context

View File

@ -1,59 +0,0 @@
# 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
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
from erpnext.setup.doctype.item_group.item_group import get_parent_item_groups
doctype = "Item Group"
condition_field = "show_in_website"
def get_context(context):
item_group_context = context.doc.as_dict()
item_group_context.update({
"items": get_product_list_for_group(product_group = context.docname, limit=100),
"parent_groups": get_parent_item_groups(context.docname),
"title": context.docname
})
if context.doc.slideshow:
item_group_context.update(get_slideshow(context.doc))
return item_group_context
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 += """order by t1.weightage desc, t1.modified desc limit %s, %s""" % (start, limit)
data = frappe.db.sql(query, {"product_group": product_group}, as_dict=1)
return [get_item_for_list_in_html(r) for r in data]
def get_child_groups(item_group_name):
item_group = frappe.get_doc("Item Group", item_group_name)
return frappe.db.sql("""select name
from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s
and show_in_website = 1""", {"lft": item_group.lft, "rgt": item_group.rgt})
def get_item_for_list_in_html(context):
return frappe.get_template("templates/includes/product_in_grid.html").render(context)
def get_group_item_count(item_group):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
return frappe.db.sql("""select count(*) from `tabItem`
where docstatus = 0 and 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))[0][0]

View File

@ -1,28 +0,0 @@
# 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
from frappe.utils import filter_strip_join
doctype = "Sales Partner"
condition_field = "show_in_website"
def get_context(context):
partner_context = context.doc.as_dict()
address = frappe.db.get_value("Address",
{"sales_partner": context.doc.name, "is_primary_address": 1},
"*", as_dict=True)
if address:
city_state = ", ".join(filter(None, [address.city, address.state]))
address_rows = [address.address_line1, address.address_line2,
city_state, address.pincode, address.country]
partner_context.update({
"email": address.email_id,
"partner_address": filter_strip_join(address_rows, "\n<br>"),
"phone": filter_strip_join(cstr(address.phone).split(","), "\n<br>")
})
return partner_context

View File

@ -1 +1 @@
<a href="http://erpnext.org" style="color: #aaa;">ERPNext Powered</a>
<a href="http://erpnext.com" style="color: #aaa; font-size: 11px;">ERPNext Powered</a>

View File

@ -9,13 +9,13 @@
<div class="col-md-3">
{% if partner_info.logo -%}
<a href="{{ partner_info.page_name }}">
<img itemprop="brand" src="{{ partner_info.logo }}" class="partner-logo"
<img itemprop="brand" src="{{ partner_info.logo }}" class="partner-logo"
alt="{{ partner_info.partner_name }}" title="{{ partner_info.partner_name }}" />
</a>
{%- endif %}
</div>
<div class="col-md-9">
<a href="{{ partner_info.page_name }}">
<a href="{{ partner_info.route }}">
<h4>{{ partner_info.partner_name }}</h4>
</a>
<p style="color: #999">{{ partner_info.territory }} - {{ partner_info.partner_type }}</p>
@ -27,4 +27,4 @@
</div>
{% endblock %}
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}
{% block sidebar %}{% include "templates/includes/sidebar.html" %}{% endblock %}

View File

@ -5,9 +5,16 @@ from __future__ import unicode_literals
import frappe
import frappe.website.render
page_title = "Partners"
def get_context(context):
partners = frappe.db.sql("""select * from `tabSales Partner`
where show_in_website=1 order by name asc""", as_dict=True)
for p in partners:
p.route = frappe.get_doc("Sales Partner", p.name).get_route()
return {
"partners": frappe.db.sql("""select * from `tabSales Partner`
where show_in_website=1 order by name asc""", as_dict=True),
"title": "Partners"
"partners": partners,
"title": page_title
}

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr
from erpnext.templates.generators.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_sitemap = 1