Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
index bee1333..964b886 100644
--- a/setup/doctype/company/company.py
+++ b/setup/doctype/company/company.py
@@ -153,7 +153,7 @@
for d in acc_list_common:
self.add_acc(d)
- country = sql("select value from tabSingles where field = 'country' and doctype = 'Control Panel'")
+ country = webnotes.conn.sql("select value from tabSingles where field = 'country' and doctype = 'Control Panel'")
country = country and cstr(country[0][0]) or ''
# load taxes (only for India)
@@ -265,26 +265,31 @@
"""
Trash accounts and cost centers for this company if no gl entry exists
"""
- rec = sql("SELECT name from `tabGL Entry` where ifnull(is_cancelled, 'No') = 'No' and company = %s", self.doc.name)
+ rec = webnotes.conn.sql("SELECT name from `tabGL Entry` where ifnull(is_cancelled, 'No') = 'No' and company = %s", self.doc.name)
if not rec:
# delete gl entry
- sql("delete from `tabGL Entry` where company = %s", self.doc.name)
+ webnotes.conn.sql("delete from `tabGL Entry` where company = %s", self.doc.name)
#delete tabAccount
- sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name)
+ webnotes.conn.sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name)
#delete cost center child table - budget detail
- sql("delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc where bd.parent = cc.name and cc.company_name = %s", self.doc.name)
+ webnotes.conn.sql("delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc where bd.parent = cc.name and cc.company_name = %s", self.doc.name)
#delete cost center
- sql("delete from `tabCost Center` WHERE company_name = %s order by lft desc, rgt desc", self.doc.name)
+ webnotes.conn.sql("delete from `tabCost Center` WHERE company_name = %s order by lft desc, rgt desc", self.doc.name)
- webnotes.defaults.clear_default("company", value=self.doc.name)
+ webnotes.defaults.clear_default("company", value=self.doc.name)
- #update value as blank for tabSingles Global Defaults
- sql("update `tabSingles` set value = '' where doctype='Global Defaults' and field = 'default_company' and value = %s", self.doc.name)
-
+ webnotes.conn.sql("""update `tabSingles` set value=""
+ where doctype='Global Defaults' and field='default_company'
+ and value=%s""", self.doc.name)
+
def on_rename(self,newdn,olddn):
- sql("update `tabCompany` set company_name = '%s' where name = '%s'" %(newdn,olddn))
- sql("update `tabSingles` set value = %s where doctype='Global Defaults' and field = 'default_company' and value = %s", (newdn, olddn))
- if webnotes.defaults.get_global_default('company') == olddn:
- webnotes.defaults.set_global_default('company', newdn)
\ No newline at end of file
+ webnotes.conn.sql("""update `tabCompany` set company_name=%s
+ where name=%s""", (newdn, olddn))
+
+ webnotes.conn.sql("""update `tabSingles` set value=%s
+ where doctype='Global Defaults' and field='default_company'
+ and value=%s""", (newdn, olddn))
+
+ webnotes.defaults.clear_default("company", value=olddn)
\ No newline at end of file
diff --git a/setup/doctype/email_digest/email_digest.py b/setup/doctype/email_digest/email_digest.py
index 0b0b21a..881e35a 100644
--- a/setup/doctype/email_digest/email_digest.py
+++ b/setup/doctype/email_digest/email_digest.py
@@ -94,8 +94,7 @@
msg_for_this_receipient = self.get_msg_html(self.get_user_specific_content(user_id) + \
common_msg)
from webnotes.utils.email_lib import sendmail
- sendmail(recipients=user_id, subject=(self.doc.frequency + " Digest"),
- sender="ERPNext Notifications <notifications+email_digest@erpnext.com>",
+ sendmail(recipients=user_id, subject="[ERPNext] " + (self.doc.frequency + " Digest"),
msg=msg_for_this_receipient)
def get_digest_msg(self):
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index 3486f92..a16296d 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -22,12 +22,10 @@
from webnotes.model.bean import getlist
from webnotes import msgprint, _
-sql = webnotes.conn.sql
-
from webnotes.model.controller import DocListController
class DocType(DocListController):
def get_tax_rate(self, tax_type):
- rate = sql("select tax_rate from tabAccount where name = %s", tax_type)
+ rate = webnotes.conn.sql("select tax_rate from tabAccount where name = %s", tax_type)
ret = {
'tax_rate' : rate and flt(rate[0][0]) or 0
}
@@ -39,7 +37,7 @@
# webpage updates
self.update_website()
- bin = sql("select stock_uom from `tabBin` where item_code = %s",
+ bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s",
self.doc.item_code)
if bin and cstr(bin[0][0]) and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
msgprint("Please Update Stock UOM with the help of Stock UOM Replace Utility.")
@@ -108,8 +106,8 @@
# On delete 1. Delete BIN (if none of the corrosponding transactions present, it gets deleted. if present, rolled back due to exception)
def on_trash(self):
- sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
- sql("""delete from `tabStock Ledger Entry`
+ webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
+ webnotes.conn.sql("""delete from `tabStock Ledger Entry`
where item_code=%s and is_cancelled='Yes' """, self.doc.item_code)
if self.doc.page_name:
@@ -150,7 +148,7 @@
def check_for_active_boms(self, field_label):
if field_label in ['Is Active', 'Is Purchase Item']:
- bom_mat = sql("select distinct t1.parent from `tabBOM Item` t1, `tabBOM` t2 where t1.item_code =%s and (t1.bom_no = '' or t1.bom_no is NULL) and t2.name = t1.parent and t2.is_active = 1 and t2.docstatus = 1 and t1.docstatus =1 ", self.doc.name)
+ bom_mat = webnotes.conn.sql("select distinct t1.parent from `tabBOM Item` t1, `tabBOM` t2 where t1.item_code =%s and (t1.bom_no = '' or t1.bom_no is NULL) and t2.name = t1.parent and t2.is_active = 1 and t2.docstatus = 1 and t1.docstatus =1 ", self.doc.name)
if bom_mat and bom_mat[0][0]:
msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(field_label), cstr(self.doc.name)))
raise Exception
@@ -158,25 +156,27 @@
and self.doc.is_sub_contracted_item != 'Yes')
or (field_label == 'Is Sub Contracted Item'
and self.doc.is_manufactured_item != 'Yes')):
- bom = sql("select name from `tabBOM` where item = %s and is_active = 1", self.doc.name)
+ bom = webnotes.conn.sql("select name from `tabBOM` where item = %s and is_active = 1",
+ (self.doc.name,))
if bom and bom[0][0]:
msgprint("%s should be 'Yes'. As Item %s is present in one or many Active BOMs." % (cstr(field_label), cstr(self.doc.name)))
raise Exception
def validate_barcode(self):
if self.doc.barcode:
- duplicate = sql("select name from tabItem where barcode = %s and name != %s", (self.doc.barcode, self.doc.name))
+ duplicate = webnotes.conn.sql("select name from tabItem where barcode = %s and name != %s", (self.doc.barcode, self.doc.name))
if duplicate:
msgprint("Barcode: %s already used in item: %s" % (self.doc.barcode, cstr(duplicate[0][0])), raise_exception = 1)
def validate(self):
- fl = {'is_manufactured_item' :'Allow Bill of Materials',
+ if not cint(self.doc.fields.get("__islocal")):
+ fl = {'is_manufactured_item' :'Allow Bill of Materials',
'is_sub_contracted_item':'Is Sub Contracted Item',
'is_purchase_item' :'Is Purchase Item',
'is_pro_applicable' :'Allow Production Order'}
- for d in fl:
- if cstr(self.doc.fields.get(d)) != 'Yes':
- self.check_for_active_boms(fl[d])
+ for d in fl:
+ if cstr(self.doc.fields.get(d)) != 'Yes':
+ self.check_for_active_boms(fl[d])
self.check_ref_rate_detail()
self.fill_customer_code()
self.check_item_tax()
@@ -198,7 +198,7 @@
def check_non_asset_warehouse(self):
if self.doc.is_asset_item == "Yes":
- existing_qty = sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
+ existing_qty = webnotes.conn.sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
for e in existing_qty:
msgprint("%s Units exist in Warehouse %s, which is not an Asset Warehouse." % (e[1],e[0]))
if existing_qty:
@@ -207,7 +207,7 @@
raise Exception
def get_file_details(self, arg = ''):
- file = sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)
+ file = webnotes.conn.sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)
ret = {
'file_group' : file and file[0]['file_group'] or '',
@@ -217,11 +217,11 @@
def check_if_sle_exists(self):
- sle = sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
+ sle = webnotes.conn.sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
return sle and 'exists' or 'not exists'
def on_rename(self,newdn,olddn):
- sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
+ webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
if self.doc.page_name:
from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name)
diff --git a/website/doctype/website_settings/website_settings.txt b/website/doctype/website_settings/website_settings.txt
index a39144c..0ebc75b 100644
--- a/website/doctype/website_settings/website_settings.txt
+++ b/website/doctype/website_settings/website_settings.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-07 11:55:11",
+ "creation": "2013-03-26 06:51:18",
"docstatus": 0,
- "modified": "2013-03-13 16:25:22",
+ "modified": "2013-04-17 11:51:24",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -50,7 +50,7 @@
"fieldtype": "Link",
"label": "Home Page",
"options": "Web Page",
- "reqd": 1
+ "reqd": 0
},
{
"description": "The name of your company / website as you want to appear on browser title bar. All pages will have this as the prefix to the title.",
@@ -240,13 +240,6 @@
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
- "role": "System Manager",
- "write": 1
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "permlevel": 0,
"role": "Website Manager",
"write": 1
},
diff --git a/website/helpers/sitemap.py b/website/helpers/sitemap.py
index 201865a..c8b6fd0 100644
--- a/website/helpers/sitemap.py
+++ b/website/helpers/sitemap.py
@@ -14,25 +14,40 @@
import urllib, os
import webnotes
import webnotes.webutils
+ from webnotes.utils import nowdate
# settings
- max_doctypes = 10
max_items = 1000
+ count = 0
site_map = ''
- page_list = []
-
if domain:
- # list of all pages in web cache
- for doctype in webnotes.webutils.page_map:
- d = webnotes.webutils.page_map[doctype];
+ today = nowdate()
+
+ # generated pages
+ for doctype, opts in webnotes.webutils.get_generators().items():
pages = webnotes.conn.sql("""select page_name, `modified`
from `tab%s` where ifnull(%s,0)=1
- order by modified desc""" % (doctype, d.condition_field))
+ order by modified desc""" % (doctype, opts.get("condition_field")))
for p in pages:
+ if count >= max_items: break
page_url = os.path.join(domain, urllib.quote(p[0]))
modified = p[1].strftime('%Y-%m-%d')
site_map += link_xml % (page_url, modified)
+ count += 1
+
+ if count >= max_items: break
+
+ # standard pages
+ for page, opts in webnotes.get_config()["web"]["pages"].items():
+ if "no_cache" in opts:
+ continue
+
+ if count >= max_items: break
+ page_url = os.path.join(domain, urllib.quote(page))
+ modified = today
+ site_map += link_xml % (page_url, modified)
+ count += 1
- return frame_xml % site_map
+ return frame_xml % site_map