blob: 896a6cdc72611f4d24d5ead8af23f3871fb467f6 [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 Mehta982ad352013-07-10 18:39:06 +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
Rushabh Mehtaad714732013-07-10 18:59:55 +0530103 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
104 {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
105 {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
106 {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530107
108 # deduction type
109 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
110 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
111 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
112
113 # earning type
114 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
115 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
116
117 # expense claim type
118 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
119 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
120 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
121 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
122 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
123
124 # leave type
125 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
126 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
127 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
128 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
129 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
130
131 # territory
132 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530133
134 # customer group
135 {'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 +0530136 {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
137 {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
138 {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
139 {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530140
141 # supplier type
Rushabh Mehtaad714732013-07-10 18:59:55 +0530142 {'doctype': 'Supplier Type', 'supplier_type': 'Services'},
143 {'doctype': 'Supplier Type', 'supplier_type': 'Local'},
144 {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
145 {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
146 {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
147 {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
148 {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530149
150 # Sales Person
Rushabh Mehtaad714732013-07-10 18:59:55 +0530151 {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530152
153 # UOM
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530154 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530155 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530156 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530157 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos'},
158 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair'},
159 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530160 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
161 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530162 ]
163
Anand Doshi4ee647e2013-07-08 18:50:45 +0530164 from webnotes.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530165 for r in records:
Rushabh Mehtae41bceb2013-07-10 20:42:44 +0530166 bean = webnotes.bean(r)
167
168 # ignore mandatory for root
169 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
170 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
171 bean.ignore_mandatory = True
172
173 bean.insert()