blob: 0824c6ca7816d3f029a86daf7966e2bd2e910ec9 [file] [log] [blame]
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
2# 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
8def pre_import():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +05309 webnotes.conn.begin()
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053010 make_modules()
11 make_roles()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053012 webnotes.conn.commit()
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053013
14def make_modules():
15 modules = [
Rushabh Mehta982ad352013-07-10 18:39:06 +053016 "Home", "System", "Utilities", "Website", "Setup",
17 "Selling", "Buying", "Projects", "Accounts", "Stock",
18 "Support", "HR", "Manufacturing"]
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053019
20 for m in modules:
21 doc = webnotes.doc(fielddata = {
22 "doctype": "Module Def",
23 "module_name": m,
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053024 })
25 doc.insert()
26
27def make_roles():
28 roles = [
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053029 "Accounts Manager", "Accounts User", "Analytics", "Auditor",
30 "Blogger", "Customer", "Employee", "Expense Approver",
31 "HR Manager", "HR User", "Leave Approver", "Maintenance Manager",
32 "Maintenance User", "Manufacturing Manager", "Manufacturing User",
33 "Material Manager", "Material Master Manager", "Material User",
Rushabh Mehtaed196662013-02-26 16:36:41 +053034 "Partner", "Projects User", "Projects Manager", "Purchase Manager", "Purchase Master Manager",
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053035 "Purchase User", "Quality Manager", "Sales Manager",
36 "Sales Master Manager", "Sales User", "Supplier", "Support Manager",
Anand Doshi3422bdf2013-02-12 13:03:25 +053037 "Support Team", "Website Manager"]
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053038
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053039 for r in roles:
40 doc = webnotes.doc(fielddata = {
41 "doctype":"Role",
42 "role_name": r
43 })
44 doc.insert()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053045
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053046def post_import():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053047 webnotes.conn.begin()
Rushabh Mehtaa94d1af2013-06-25 12:36:13 +053048
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053049 # feature setup
50 import_defaults()
51 import_country_and_currency()
52
53 # home page
54 webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')
55
56 # features
57 feature_setup()
58
59 # all roles to Administrator
60 from setup.doctype.setup_control.setup_control import add_all_roles_to
61 add_all_roles_to("Administrator")
62
63 webnotes.conn.commit()
64
65def feature_setup():
66 """save global defaults and features setup"""
67 doc = webnotes.doc("Features Setup", "Features Setup")
68
69 # store value as 1 for all these fields
70 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
71 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
72 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
73 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
74 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
75 'fs_page_break', 'fs_more_info'
76 ]
77 doc.fields.update(dict(zip(flds, [1]*len(flds))))
78 doc.save()
79
80def import_country_and_currency():
81 from webnotes.country_info import get_all
82 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053083
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053084 for name in data:
85 country = webnotes._dict(data[name])
86 webnotes.doc({
87 "doctype": "Country",
88 "country_name": name,
89 "date_format": country.date_format or "dd-mm-yyyy",
90 "time_zones": "\n".join(country.timezones or [])
91 }).insert()
92
Anand Doshi44077d22013-01-27 17:02:49 +053093 if country.currency and not webnotes.conn.exists("Currency", country.currency):
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053094 webnotes.doc({
95 "doctype": "Currency",
96 "currency_name": country.currency,
97 "fraction": country.currency_fraction,
98 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +053099 "fraction_units": country.currency_fraction_units,
100 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530101 }).insert()
102
103def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530104 records = [
105 # item group
Rushabh Mehtaad714732013-07-10 18:59:55 +0530106 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
107 {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
108 {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
109 {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530110
111 # deduction type
112 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
113 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
114 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
115
116 # earning type
117 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
118 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
119
120 # expense claim type
121 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
122 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
123 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
124 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
125 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
126
127 # leave type
128 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
129 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
130 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
131 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
132 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
133
134 # territory
135 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530136
137 # customer group
138 {'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 +0530139 {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
140 {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
141 {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
142 {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530143
144 # supplier type
Rushabh Mehtaad714732013-07-10 18:59:55 +0530145 {'doctype': 'Supplier Type', 'supplier_type': 'Services'},
146 {'doctype': 'Supplier Type', 'supplier_type': 'Local'},
147 {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
148 {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
149 {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
150 {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
151 {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530152
153 # Sales Person
Rushabh Mehtaad714732013-07-10 18:59:55 +0530154 {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530155
156 # UOM
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530157 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
158 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530159 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530160 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
161 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
162 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
163 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530164 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530165 ]
166
Anand Doshi4ee647e2013-07-08 18:50:45 +0530167 from webnotes.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530168 for r in records:
Rushabh Mehtae41bceb2013-07-10 20:42:44 +0530169 bean = webnotes.bean(r)
170
171 # ignore mandatory for root
172 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
173 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
174 bean.ignore_mandatory = True
175
176 bean.insert()