blob: b42b7163c023cbb45458e611169c8842ad15e37e [file] [log] [blame]
Rushabh Mehta6f9915c2013-01-16 17:48:17 +05301from __future__ import unicode_literals
2
3import webnotes
4
5def pre_import():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +05306 webnotes.conn.begin()
Rushabh Mehta6f9915c2013-01-16 17:48:17 +05307 make_modules()
8 make_roles()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +05309 webnotes.conn.commit()
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053010 webnotes.reload_doc("utilities", "doctype", "gl_mapper")
11 webnotes.reload_doc("utilities", "doctype", "gl_mapper_detail")
12
13def make_modules():
14 modules = [
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053015 " Home", " System", " Utilities", " Website", " Setup",
16 " Selling", " Buying", " Projects", " Accounts", " Stock",
17 " Support", " HR", " Manufacturing"]
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053018
19 for m in modules:
20 doc = webnotes.doc(fielddata = {
21 "doctype": "Module Def",
22 "module_name": m,
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053023 })
24 doc.insert()
25
26def make_roles():
27 roles = [
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053028 "Accounts Manager", "Accounts User", "Analytics", "Auditor",
29 "Blogger", "Customer", "Employee", "Expense Approver",
30 "HR Manager", "HR User", "Leave Approver", "Maintenance Manager",
31 "Maintenance User", "Manufacturing Manager", "Manufacturing User",
32 "Material Manager", "Material Master Manager", "Material User",
33 "Partner", "Projects User", "Purchase Manager", "Purchase Master Manager",
34 "Purchase User", "Quality Manager", "Sales Manager",
35 "Sales Master Manager", "Sales User", "Supplier", "Support Manager",
Anand Doshi3422bdf2013-02-12 13:03:25 +053036 "Support Team", "Website Manager"]
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053037
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053038 for r in roles:
39 doc = webnotes.doc(fielddata = {
40 "doctype":"Role",
41 "role_name": r
42 })
43 doc.insert()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053044
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053045def post_import():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053046 webnotes.conn.begin()
47 # feature setup
48 import_defaults()
49 import_country_and_currency()
50
51 # home page
52 webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')
53
54 # features
55 feature_setup()
56
57 # all roles to Administrator
58 from setup.doctype.setup_control.setup_control import add_all_roles_to
59 add_all_roles_to("Administrator")
60
61 webnotes.conn.commit()
62
63def feature_setup():
64 """save global defaults and features setup"""
65 doc = webnotes.doc("Features Setup", "Features Setup")
66
67 # store value as 1 for all these fields
68 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
69 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
70 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
71 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
72 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
73 'fs_page_break', 'fs_more_info'
74 ]
75 doc.fields.update(dict(zip(flds, [1]*len(flds))))
76 doc.save()
77
78def import_country_and_currency():
79 from webnotes.country_info import get_all
80 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053081
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053082 for name in data:
83 country = webnotes._dict(data[name])
84 webnotes.doc({
85 "doctype": "Country",
86 "country_name": name,
87 "date_format": country.date_format or "dd-mm-yyyy",
88 "time_zones": "\n".join(country.timezones or [])
89 }).insert()
90
Anand Doshi44077d22013-01-27 17:02:49 +053091 if country.currency and not webnotes.conn.exists("Currency", country.currency):
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053092 webnotes.doc({
93 "doctype": "Currency",
94 "currency_name": country.currency,
95 "fraction": country.currency_fraction,
96 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +053097 "fraction_units": country.currency_fraction_units,
98 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053099 }).insert()
100
101def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530102 records = [
103 # item group
104 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'name': 'All Item Groups', 'parent_item_group': ''},
105 {'doctype': 'Item Group', 'item_group_name': 'Default', 'is_group': 'No', 'name': 'Default', 'parent_item_group': 'All Item Groups'},
106
107 # deduction type
108 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
109 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
110 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
111
112 # earning type
113 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
114 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
115
116 # expense claim type
117 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
118 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
119 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
120 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
121 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
122
123 # leave type
124 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
125 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
126 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
127 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
128 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
129
130 # territory
131 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
132 {'doctype': 'Territory', 'territory_name': 'Default', 'is_group': 'No', 'name': 'Default', 'parent_territory': 'All Territories'},
133
134 # customer group
135 {'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''},
136 {'doctype': 'Customer Group', 'customer_group_name': 'Default Customer Group', 'is_group': 'No', 'name': 'Default Customer Group', 'parent_customer_group': 'All Customer Groups'},
137
138 # supplier type
139 {'doctype': 'Supplier Type', 'name': 'Default Supplier Type', 'supplier_type': 'Default Supplier Type'},
140
141 # Price List
142 {'doctype': 'Price List', 'name': 'Default Price List', 'price_list_name': 'Default Price List'},
143 {'doctype': 'Price List', 'name': 'Standard', 'price_list_name': 'Standard'},
144
145 # warehouse type
146 {'doctype': 'Warehouse Type', 'name': 'Default Warehouse Type', 'warehouse_type': 'Default Warehouse Type'},
147 {'doctype': 'Warehouse Type', 'name': 'Fixed Asset', 'warehouse_type': 'Fixed Asset'},
148 {'doctype': 'Warehouse Type', 'name': 'Reserved', 'warehouse_type': 'Reserved'},
149 {'doctype': 'Warehouse Type', 'name': 'Rejected', 'warehouse_type': 'Rejected'},
150 {'doctype': 'Warehouse Type', 'name': 'Sample', 'warehouse_type': 'Sample'},
151 {'doctype': 'Warehouse Type', 'name': 'Stores', 'warehouse_type': 'Stores'},
152 {'doctype': 'Warehouse Type', 'name': 'WIP Warehouse', 'warehouse_type': 'WIP Warehouse'},
153
154 # warehouse
155 {'doctype': 'Warehouse', 'warehouse_name': 'Default Warehouse', 'name': 'Default Warehouse', 'warehouse_type': 'Default Warehouse Type'},
156
157 # Workstation
158 {'doctype': 'Workstation', 'name': 'Default Workstation', 'workstation_name': 'Default Workstation', 'warehouse': 'Default Warehouse'},
159
160 # Sales Person
161 {'doctype': 'Sales Person', 'name': 'All Sales Persons', 'sales_person_name': 'All Sales Persons', 'is_group': "Yes", "parent_sales_person": ""},
162
163 # UOM
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530164 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530165 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box'},
166 {'uom_name': 'Ft', 'doctype': 'UOM', 'name': 'Ft'},
167 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
168 {'uom_name': 'Ltr', 'doctype': 'UOM', 'name': 'Ltr'},
169 {'uom_name': 'Meter', 'doctype': 'UOM', 'name': 'Meter'},
170 {'uom_name': 'Mtr', 'doctype': 'UOM', 'name': 'Mtr'},
171 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos'},
172 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair'},
173 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530174 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
175 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530176 ]
177
178 for r in records:
179 doc = webnotes.doc(r)
180 doc.insert()
181