mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 18:21:22 +00:00
Merge branch 'responsive' of git://github.com/webnotes/erpnext into responsive
This commit is contained in:
@@ -14,13 +14,7 @@ def boot_session(bootinfo):
|
||||
bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
|
||||
bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')
|
||||
|
||||
if webnotes.session['user']=='Guest':
|
||||
bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page,
|
||||
parent_label, parentfield
|
||||
from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1)
|
||||
bootinfo['startup_code'] = \
|
||||
webnotes.conn.get_value('Website Settings', None, 'startup_code')
|
||||
else:
|
||||
if webnotes.session['user']!='Guest':
|
||||
bootinfo['letter_heads'] = get_letter_heads()
|
||||
|
||||
import webnotes.model.doctype
|
||||
@@ -36,9 +30,8 @@ def boot_session(bootinfo):
|
||||
for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
|
||||
if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
|
||||
|
||||
bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center,
|
||||
cost_center as 'cost_center_other_charges' from `tabCompany`""",
|
||||
as_dict=1, update={"doctype":":Company"})
|
||||
bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
|
||||
from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
|
||||
|
||||
def get_letter_heads():
|
||||
"""load letter heads with startup"""
|
||||
|
||||
@@ -7,8 +7,6 @@ def pre_import():
|
||||
make_modules()
|
||||
make_roles()
|
||||
webnotes.conn.commit()
|
||||
webnotes.reload_doc("utilities", "doctype", "gl_mapper")
|
||||
webnotes.reload_doc("utilities", "doctype", "gl_mapper_detail")
|
||||
|
||||
def make_modules():
|
||||
modules = [
|
||||
@@ -129,18 +127,19 @@ def import_defaults():
|
||||
|
||||
# territory
|
||||
{'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
|
||||
{'doctype': 'Territory', 'territory_name': 'Default', 'is_group': 'No', 'name': 'Default', 'parent_territory': 'All Territories'},
|
||||
|
||||
# customer group
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''},
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'Default Customer Group', 'is_group': 'No', 'name': 'Default Customer Group', 'parent_customer_group': 'All Customer Groups'},
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'Default', 'is_group': 'No', 'name': 'Default Customer Group', 'parent_customer_group': 'All Customer Groups'},
|
||||
|
||||
# supplier type
|
||||
{'doctype': 'Supplier Type', 'name': 'Default Supplier Type', 'supplier_type': 'Default Supplier Type'},
|
||||
|
||||
# Price List
|
||||
{'doctype': 'Price List', 'name': 'Default Price List', 'price_list_name': 'Default Price List'},
|
||||
{'doctype': 'Price List', 'name': 'Standard', 'price_list_name': 'Standard'},
|
||||
{'doctype': 'Price List', 'name': 'Default Price List', 'price_list_name': 'Default Price List',
|
||||
"buying_or_selling": "Selling"},
|
||||
{'doctype': 'Price List', 'name': 'Standard', 'price_list_name': 'Standard',
|
||||
"buying_or_selling": "Selling"},
|
||||
|
||||
# warehouse type
|
||||
{'doctype': 'Warehouse Type', 'name': 'Default Warehouse Type', 'warehouse_type': 'Default Warehouse Type'},
|
||||
@@ -176,6 +175,6 @@ def import_defaults():
|
||||
]
|
||||
|
||||
for r in records:
|
||||
doc = webnotes.doc(r)
|
||||
doc.insert()
|
||||
bean = webnotes.bean(r)
|
||||
bean.insert()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
queries = {
|
||||
for_doctype = {
|
||||
"Support Ticket": {"status":"Open"},
|
||||
"Customer Issue": {"status":"Open"},
|
||||
"Task": {"status":"Open"},
|
||||
@@ -29,4 +29,39 @@ queries = {
|
||||
"Timesheet": {"docstatus":0},
|
||||
"Time Log": {"status":"Draft"},
|
||||
"Time Log Batch": {"status":"Draft"},
|
||||
}
|
||||
}
|
||||
|
||||
def get_things_todo():
|
||||
"""Returns a count of incomplete todos"""
|
||||
incomplete_todos = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabToDo`
|
||||
WHERE IFNULL(checked, 0) = 0
|
||||
AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
|
||||
return incomplete_todos[0][0]
|
||||
|
||||
def get_todays_events():
|
||||
"""Returns a count of todays events in calendar"""
|
||||
from webnotes.utils import nowdate
|
||||
todays_events = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabEvent`
|
||||
WHERE owner = %s
|
||||
AND event_type != 'Cancel'
|
||||
AND %s between date(starts_on) and date(ends_on)""", (
|
||||
webnotes.session.user, nowdate()))
|
||||
return todays_events[0][0]
|
||||
|
||||
def get_unread_messages():
|
||||
"returns unread (docstatus-0 messages for a user)"
|
||||
return webnotes.conn.sql("""\
|
||||
SELECT count(*)
|
||||
FROM `tabComment`
|
||||
WHERE comment_doctype IN ('My Company', 'Message')
|
||||
AND comment_docname = %s
|
||||
AND ifnull(docstatus,0)=0
|
||||
""", webnotes.user.name)[0][0]
|
||||
|
||||
for_module = {
|
||||
"To Do": get_things_todo,
|
||||
"Calendar": get_todays_events,
|
||||
"Messages": get_unread_messages
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
def get_unread_messages():
|
||||
"returns unread (docstatus-0 messages for a user)"
|
||||
return webnotes.conn.sql("""\
|
||||
SELECT count(*)
|
||||
FROM `tabComment`
|
||||
WHERE comment_doctype IN ('My Company', 'Message')
|
||||
AND comment_docname = %s
|
||||
AND ifnull(docstatus,0)=0
|
||||
""", webnotes.user.name)[0][0]
|
||||
|
||||
def get_open_support_tickets():
|
||||
"""Returns a count of open support tickets"""
|
||||
open_support_tickets = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabSupport Ticket`
|
||||
WHERE status = 'Open'""")
|
||||
return open_support_tickets[0][0]
|
||||
|
||||
def get_open_tasks():
|
||||
"""Returns a count of open tasks"""
|
||||
return webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabTask`
|
||||
WHERE status = 'Open'""")[0][0]
|
||||
|
||||
def get_things_todo():
|
||||
"""Returns a count of incomplete todos"""
|
||||
incomplete_todos = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabToDo`
|
||||
WHERE IFNULL(checked, 0) = 0
|
||||
AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
|
||||
return incomplete_todos[0][0]
|
||||
|
||||
def get_todays_events():
|
||||
"""Returns a count of todays events in calendar"""
|
||||
from webnotes.utils import nowdate
|
||||
todays_events = webnotes.conn.sql("""\
|
||||
SELECT COUNT(*) FROM `tabEvent`
|
||||
WHERE owner = %s
|
||||
AND event_type != 'Cancel'
|
||||
AND %s between date(starts_on) and date(ends_on)""", (
|
||||
webnotes.session.user, nowdate()))
|
||||
return todays_events[0][0]
|
||||
|
||||
def get_open_leads():
|
||||
return webnotes.conn.sql("""select count(*) from tabLead
|
||||
where status='Open'""")[0][0]
|
||||
|
||||
def get_unanswered_questions():
|
||||
return len(filter(lambda d: d[0]==0,
|
||||
webnotes.conn.sql("""select (select count(*) from tabAnswer
|
||||
where tabAnswer.question = tabQuestion.name) as answers from tabQuestion""")))
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_global_status_messages(arg=None):
|
||||
return {
|
||||
'unread_messages': get_unread_messages(),
|
||||
'open_support_tickets': get_open_support_tickets(),
|
||||
'things_todo': get_things_todo(),
|
||||
'todays_events': get_todays_events(),
|
||||
'open_tasks': get_open_tasks(),
|
||||
'unanswered_questions': get_unanswered_questions(),
|
||||
'open_leads': get_open_leads()
|
||||
}
|
||||
@@ -34,18 +34,7 @@ def update_template_args(page_name, args):
|
||||
t['child_items'] = []
|
||||
t['child_items'].append(d)
|
||||
break
|
||||
|
||||
if top_items and ("products" in [d.url.split(".")[0] for d in top_items if d.url]):
|
||||
# product categories
|
||||
products = webnotes.conn.sql("""select t1.item_group as label,
|
||||
t2.page_name as url,
|
||||
ifnull(t1.indent,0) as indent
|
||||
from `tabWebsite Product Category` t1, `tabItem Group` t2
|
||||
where t1.item_group = t2.name
|
||||
and ifnull(t2.show_in_website,0)=1 order by t1.idx""", as_dict=1)
|
||||
products_item = filter(lambda d: d.url and d.url.split(".")[0]=="products", top_items)[0]
|
||||
products_item.child_items = products
|
||||
|
||||
|
||||
ret = webnotes._dict({
|
||||
'top_bar_items': top_items,
|
||||
'footer_items': webnotes.conn.sql("""\
|
||||
|
||||
Reference in New Issue
Block a user