blob: 00b7b84d9faca7132335dfdf8b9835be14119b7c [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,
23 "disabled":"No"
24 })
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",
34 "Partner", "Projects User", "Purchase Manager", "Purchase Master Manager",
35 "Purchase User", "Quality Manager", "Sales Manager",
36 "Sales Master Manager", "Sales User", "Supplier", "Support Manager",
37 "Support Team"]
38
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()
48 # feature setup
49 import_defaults()
50 import_country_and_currency()
51
52 # home page
53 webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')
54
55 # features
56 feature_setup()
57
58 # all roles to Administrator
59 from setup.doctype.setup_control.setup_control import add_all_roles_to
60 add_all_roles_to("Administrator")
61
62 webnotes.conn.commit()
63
64def feature_setup():
65 """save global defaults and features setup"""
66 doc = webnotes.doc("Features Setup", "Features Setup")
67
68 # store value as 1 for all these fields
69 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
70 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
71 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
72 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
73 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
74 'fs_page_break', 'fs_more_info'
75 ]
76 doc.fields.update(dict(zip(flds, [1]*len(flds))))
77 doc.save()
78
79def import_country_and_currency():
80 from webnotes.country_info import get_all
81 data = get_all()
82 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
91 if country.currency:
92 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