blob: f96d9e11ed7b2a0566e0dc81eb41056feba77ed2 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt"
Rushabh Mehta74506e92013-03-25 17:52:14 +05303
4
5from __future__ import unicode_literals
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05306import frappe
Rushabh Mehta74506e92013-03-25 17:52:14 +05307
8def boot_session(bootinfo):
9 """boot session - send website info if guest"""
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053010 import frappe
Rushabh Mehta430d1322014-05-31 10:36:04 +053011
Anand Doshi6dfd4302015-02-10 14:41:27 +053012 print "erpnext boot session"
13
Rushabh Mehta430d1322014-05-31 10:36:04 +053014 bootinfo.custom_css = frappe.db.get_value('Style Settings', None, 'custom_css') or ''
15 bootinfo.website_settings = frappe.get_doc('Website Settings')
Rushabh Mehta74506e92013-03-25 17:52:14 +053016
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053017 if frappe.session['user']!='Guest':
Rushabh Mehta430d1322014-05-31 10:36:04 +053018 bootinfo.letter_heads = get_letter_heads()
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053019
Rushabh Mehta430d1322014-05-31 10:36:04 +053020 update_page_info(bootinfo)
21
22 load_country_and_currency(bootinfo)
23
24 bootinfo.notification_settings = frappe.get_doc("Notification Control",
25 "Notification Control")
26
27 # if no company, show a dialog box to create a new company
28 bootinfo.customer_count = frappe.db.sql("""select count(*) from tabCustomer""")[0][0]
29
30 if not bootinfo.customer_count:
31 bootinfo.setup_complete = frappe.db.sql("""select name from
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053032 tabCompany limit 1""") and 'Yes' or 'No'
Rushabh Mehta430d1322014-05-31 10:36:04 +053033
34 bootinfo.docs += frappe.db.sql("""select name, default_currency, cost_center
Anand Doshiaeef7bd2013-04-19 16:21:55 +053035 from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053036
37def load_country_and_currency(bootinfo):
Rushabh Mehtaa504f062014-04-04 12:16:26 +053038 country = frappe.db.get_default("country")
39 if country and frappe.db.exists("Country", country):
Rushabh Mehta430d1322014-05-31 10:36:04 +053040 bootinfo.docs += [frappe.get_doc("Country", country)]
41
42 bootinfo.docs += frappe.db.sql("""select * from tabCurrency
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053043 where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
44
Rushabh Mehta74506e92013-03-25 17:52:14 +053045def get_letter_heads():
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053046 import frappe
Rushabh Mehta430d1322014-05-31 10:36:04 +053047 ret = frappe.db.sql("""select name, content from `tabLetter Head`
Rushabh Mehta74506e92013-03-25 17:52:14 +053048 where ifnull(disabled,0)=0""")
49 return dict(ret)
Rushabh Mehta430d1322014-05-31 10:36:04 +053050
51def update_page_info(bootinfo):
52 bootinfo.page_info.update({
53 "Chart of Accounts": {
54 "title": "Chart of Accounts",
55 "route": "Accounts Browser/Account"
56 },
57 "Chart of Cost Centers": {
58 "title": "Chart of Cost Centers",
59 "route": "Accounts Browser/Cost Center"
60 },
61 "Item Group Tree": {
62 "title": "Item Group Tree",
63 "route": "Sales Browser/Item Group"
64 },
65 "Customer Group Tree": {
66 "title": "Customer Group Tree",
67 "route": "Sales Browser/Customer Group"
68 },
69 "Territory Tree": {
70 "title": "Territory Tree",
71 "route": "Sales Browser/Territory"
72 },
73 "Sales Person Tree": {
74 "title": "Sales Person Tree",
75 "route": "Sales Browser/Sales Person"
76 }
77 })