blob: 6f62673f41f7e49f83f2b56dd24bbc1353976c43 [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
3
Rushabh Mehta6f9915c2013-01-16 17:48:17 +05304from __future__ import unicode_literals
5
6import webnotes
7
Rushabh Mehta1f847992013-12-12 19:12:19 +05308def get_hooks():
9 return {
10 "app_include_js": ["assets/js/erpnext.min.js"],
11 "app_include_css": ["assets/css/erpnext.css"],
12 "desktop_icons": get_desktop_icons(),
13 "boot_session": ["erpnext.startup.boot.boot_session"]
14 }
Rushabh Mehtaa94d1af2013-06-25 12:36:13 +053015
Rushabh Mehta1f847992013-12-12 19:12:19 +053016def after_install():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053017 import_defaults()
18 import_country_and_currency()
Rushabh Mehta8c5a5f12013-10-08 17:59:11 +053019 webnotes.conn.set_value('Control Panel', None, 'home_page', 'setup-wizard')
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053020 feature_setup()
Rushabh Mehta1f847992013-12-12 19:12:19 +053021 from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053022 add_all_roles_to("Administrator")
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053023 webnotes.conn.commit()
24
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053025def import_country_and_currency():
26 from webnotes.country_info import get_all
27 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053028
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053029 for name in data:
30 country = webnotes._dict(data[name])
31 webnotes.doc({
32 "doctype": "Country",
33 "country_name": name,
34 "date_format": country.date_format or "dd-mm-yyyy",
35 "time_zones": "\n".join(country.timezones or [])
36 }).insert()
37
Anand Doshi44077d22013-01-27 17:02:49 +053038 if country.currency and not webnotes.conn.exists("Currency", country.currency):
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053039 webnotes.doc({
40 "doctype": "Currency",
41 "currency_name": country.currency,
42 "fraction": country.currency_fraction,
43 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +053044 "fraction_units": country.currency_fraction_units,
45 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053046 }).insert()
47
48def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053049 records = [
50 # item group
Rushabh Mehtaad714732013-07-10 18:59:55 +053051 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
52 {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
53 {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
54 {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053055 {'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehtaddca90e2013-10-09 16:08:54 +053056 {'doctype': 'Item Group', 'item_group_name': 'Consumable', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053057
58 # deduction type
59 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
60 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
61 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
62
63 # earning type
64 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
65 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
66
67 # expense claim type
68 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
69 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
70 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
71 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
72 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
73
74 # leave type
75 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
76 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
77 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
78 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
79 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
80
81 # territory
82 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053083
84 # customer group
85 {'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''},
Rushabh Mehtaad714732013-07-10 18:59:55 +053086 {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
87 {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
88 {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
89 {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053090
91 # supplier type
Rushabh Mehtaad714732013-07-10 18:59:55 +053092 {'doctype': 'Supplier Type', 'supplier_type': 'Services'},
93 {'doctype': 'Supplier Type', 'supplier_type': 'Local'},
94 {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
95 {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
96 {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
97 {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
98 {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053099
100 # Sales Person
Rushabh Mehtaad714732013-07-10 18:59:55 +0530101 {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530102
103 # UOM
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530104 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
105 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530106 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530107 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
108 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
109 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
110 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530111 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530112 ]
113
Anand Doshi4ee647e2013-07-08 18:50:45 +0530114 from webnotes.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530115 for r in records:
Rushabh Mehtae41bceb2013-07-10 20:42:44 +0530116 bean = webnotes.bean(r)
117
118 # ignore mandatory for root
119 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
120 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
121 bean.ignore_mandatory = True
122
Rushabh Mehta1f847992013-12-12 19:12:19 +0530123 bean.insert()
124
125def feature_setup():
126 """save global defaults and features setup"""
127 bean = webnotes.bean("Features Setup", "Features Setup")
128 bean.ignore_permissions = True
129
130 # store value as 1 for all these fields
131 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
132 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
133 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
134 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
135 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
136 'fs_page_break', 'fs_more_info', 'fs_pos_view'
137 ]
138 bean.doc.fields.update(dict(zip(flds, [1]*len(flds))))
139 bean.save()
140
141def get_desktop_icons():
142 return {
143 "Accounts": {
144 "color": "#3498db",
145 "icon": "icon-money",
146 "link": "accounts-home",
147 "type": "module"
148 },
149 "Activity": {
150 "color": "#e67e22",
151 "icon": "icon-play",
152 "label": "Activity",
153 "link": "activity",
154 "type": "page"
155 },
156 "Buying": {
157 "color": "#c0392b",
158 "icon": "icon-shopping-cart",
159 "link": "buying-home",
160 "type": "module"
161 },
162 "HR": {
163 "color": "#2ecc71",
164 "icon": "icon-group",
165 "label": "Human Resources",
166 "link": "hr-home",
167 "type": "module"
168 },
169 "Manufacturing": {
170 "color": "#7f8c8d",
171 "icon": "icon-cogs",
172 "link": "manufacturing-home",
173 "type": "module"
174 },
175 "Notes": {
176 "color": "#95a5a6",
177 "doctype": "Note",
178 "icon": "icon-file-alt",
179 "label": "Notes",
180 "link": "List/Note",
181 "type": "list"
182 },
183 "Projects": {
184 "color": "#8e44ad",
185 "icon": "icon-puzzle-piece",
186 "link": "projects-home",
187 "type": "module"
188 },
189 "Selling": {
190 "color": "#1abc9c",
191 "icon": "icon-tag",
192 "link": "selling-home",
193 "type": "module"
194 },
195 "Setup": {
196 "color": "#bdc3c7",
197 "icon": "icon-wrench",
198 "link": "Setup",
199 "type": "setup"
200 },
201 "Stock": {
202 "color": "#f39c12",
203 "icon": "icon-truck",
204 "link": "stock-home",
205 "type": "module"
206 },
207 "Support": {
208 "color": "#2c3e50",
209 "icon": "icon-phone",
210 "link": "support-home",
211 "type": "module"
212 }
213 }