blob: de60e3855a1c5f54bf2d0ccc88b5863b25a3a91e [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
11def make_modules():
12 modules = [
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053013 " Home", " System", " Utilities", " Website", " Setup",
14 " Selling", " Buying", " Projects", " Accounts", " Stock",
15 " Support", " HR", " Manufacturing"]
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053016
17 for m in modules:
18 doc = webnotes.doc(fielddata = {
19 "doctype": "Module Def",
20 "module_name": m,
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053021 })
22 doc.insert()
23
24def make_roles():
25 roles = [
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053026 "Accounts Manager", "Accounts User", "Analytics", "Auditor",
27 "Blogger", "Customer", "Employee", "Expense Approver",
28 "HR Manager", "HR User", "Leave Approver", "Maintenance Manager",
29 "Maintenance User", "Manufacturing Manager", "Manufacturing User",
30 "Material Manager", "Material Master Manager", "Material User",
Rushabh Mehtaed196662013-02-26 16:36:41 +053031 "Partner", "Projects User", "Projects Manager", "Purchase Manager", "Purchase Master Manager",
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053032 "Purchase User", "Quality Manager", "Sales Manager",
33 "Sales Master Manager", "Sales User", "Supplier", "Support Manager",
Anand Doshi3422bdf2013-02-12 13:03:25 +053034 "Support Team", "Website Manager"]
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053035
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053036 for r in roles:
37 doc = webnotes.doc(fielddata = {
38 "doctype":"Role",
39 "role_name": r
40 })
41 doc.insert()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053042
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053043def post_import():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053044 webnotes.conn.begin()
Rushabh Mehtaa94d1af2013-06-25 12:36:13 +053045
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053046 # feature setup
47 import_defaults()
48 import_country_and_currency()
49
50 # home page
51 webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')
52
53 # features
54 feature_setup()
55
56 # all roles to Administrator
57 from setup.doctype.setup_control.setup_control import add_all_roles_to
58 add_all_roles_to("Administrator")
59
60 webnotes.conn.commit()
61
62def feature_setup():
63 """save global defaults and features setup"""
64 doc = webnotes.doc("Features Setup", "Features Setup")
65
66 # store value as 1 for all these fields
67 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
68 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
69 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
70 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
71 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
72 'fs_page_break', 'fs_more_info'
73 ]
74 doc.fields.update(dict(zip(flds, [1]*len(flds))))
75 doc.save()
76
77def import_country_and_currency():
78 from webnotes.country_info import get_all
79 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053080
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053081 for name in data:
82 country = webnotes._dict(data[name])
83 webnotes.doc({
84 "doctype": "Country",
85 "country_name": name,
86 "date_format": country.date_format or "dd-mm-yyyy",
87 "time_zones": "\n".join(country.timezones or [])
88 }).insert()
89
Anand Doshi44077d22013-01-27 17:02:49 +053090 if country.currency and not webnotes.conn.exists("Currency", country.currency):
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053091 webnotes.doc({
92 "doctype": "Currency",
93 "currency_name": country.currency,
94 "fraction": country.currency_fraction,
95 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +053096 "fraction_units": country.currency_fraction_units,
97 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053098 }).insert()
99
100def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530101 records = [
102 # item group
103 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'name': 'All Item Groups', 'parent_item_group': ''},
104 {'doctype': 'Item Group', 'item_group_name': 'Default', 'is_group': 'No', 'name': 'Default', 'parent_item_group': 'All Item Groups'},
105
106 # deduction type
107 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
108 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
109 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
110
111 # earning type
112 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
113 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
114
115 # expense claim type
116 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
117 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
118 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
119 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
120 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
121
122 # leave type
123 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
124 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
125 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
126 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
127 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
128
129 # territory
130 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530131
132 # customer group
133 {'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''},
Rushabh Mehta847cfe22013-06-24 15:43:18 +0530134 {'doctype': 'Customer Group', 'customer_group_name': 'Default', 'is_group': 'No', 'name': 'Default Customer Group', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530135
136 # supplier type
137 {'doctype': 'Supplier Type', 'name': 'Default Supplier Type', 'supplier_type': 'Default Supplier Type'},
138
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530139 # warehouse type
140 {'doctype': 'Warehouse Type', 'name': 'Default Warehouse Type', 'warehouse_type': 'Default Warehouse Type'},
141 {'doctype': 'Warehouse Type', 'name': 'Fixed Asset', 'warehouse_type': 'Fixed Asset'},
142 {'doctype': 'Warehouse Type', 'name': 'Reserved', 'warehouse_type': 'Reserved'},
143 {'doctype': 'Warehouse Type', 'name': 'Rejected', 'warehouse_type': 'Rejected'},
144 {'doctype': 'Warehouse Type', 'name': 'Sample', 'warehouse_type': 'Sample'},
145 {'doctype': 'Warehouse Type', 'name': 'Stores', 'warehouse_type': 'Stores'},
146 {'doctype': 'Warehouse Type', 'name': 'WIP Warehouse', 'warehouse_type': 'WIP Warehouse'},
147
148 # warehouse
149 {'doctype': 'Warehouse', 'warehouse_name': 'Default Warehouse', 'name': 'Default Warehouse', 'warehouse_type': 'Default Warehouse Type'},
150
151 # Workstation
152 {'doctype': 'Workstation', 'name': 'Default Workstation', 'workstation_name': 'Default Workstation', 'warehouse': 'Default Warehouse'},
153
154 # Sales Person
155 {'doctype': 'Sales Person', 'name': 'All Sales Persons', 'sales_person_name': 'All Sales Persons', 'is_group': "Yes", "parent_sales_person": ""},
156
157 # UOM
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530158 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530159 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box'},
160 {'uom_name': 'Ft', 'doctype': 'UOM', 'name': 'Ft'},
161 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
162 {'uom_name': 'Ltr', 'doctype': 'UOM', 'name': 'Ltr'},
163 {'uom_name': 'Meter', 'doctype': 'UOM', 'name': 'Meter'},
164 {'uom_name': 'Mtr', 'doctype': 'UOM', 'name': 'Mtr'},
165 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos'},
166 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair'},
167 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530168 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
169 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530170 ]
171
Anand Doshi4ee647e2013-07-08 18:50:45 +0530172 from webnotes.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530173 for r in records:
Nabin Hait35254812013-07-05 11:27:26 +0530174 if not webnotes.conn.exists(r['doctype'], r['name']):
175 bean = webnotes.bean(r)
Anand Doshi4ee647e2013-07-08 18:50:45 +0530176
177 # ignore mandatory for root
178 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
179 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
180 bean.ignore_mandatory = True
181
Nabin Hait35254812013-07-05 11:27:26 +0530182 bean.insert()