blob: 655573fedf3ad536e7d628bc6f63bf5cd4cd229c [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"""
Anand Doshia29b76f2013-09-13 17:42:03 +053067 bean = webnotes.bean("Features Setup", "Features Setup")
68 bean.ignore_permissions = True
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053069
70 # store value as 1 for all these fields
71 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
72 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
73 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
74 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
75 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
Rushabh Mehta16a62fa2013-08-23 13:16:22 +053076 'fs_page_break', 'fs_more_info', 'fs_pos_view'
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053077 ]
Anand Doshia29b76f2013-09-13 17:42:03 +053078 bean.doc.fields.update(dict(zip(flds, [1]*len(flds))))
79 bean.save()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053080
81def import_country_and_currency():
82 from webnotes.country_info import get_all
83 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053084
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053085 for name in data:
86 country = webnotes._dict(data[name])
87 webnotes.doc({
88 "doctype": "Country",
89 "country_name": name,
90 "date_format": country.date_format or "dd-mm-yyyy",
91 "time_zones": "\n".join(country.timezones or [])
92 }).insert()
93
Anand Doshi44077d22013-01-27 17:02:49 +053094 if country.currency and not webnotes.conn.exists("Currency", country.currency):
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053095 webnotes.doc({
96 "doctype": "Currency",
97 "currency_name": country.currency,
98 "fraction": country.currency_fraction,
99 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +0530100 "fraction_units": country.currency_fraction_units,
101 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530102 }).insert()
103
104def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530105 records = [
106 # item group
Rushabh Mehtaad714732013-07-10 18:59:55 +0530107 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
108 {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
109 {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
110 {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +0530111 {'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530112
113 # deduction type
114 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
115 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
116 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
117
118 # earning type
119 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
120 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
121
122 # expense claim type
123 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
124 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
125 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
126 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
127 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
128
129 # leave type
130 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
131 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
132 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
133 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
134 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
135
136 # territory
137 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530138
139 # customer group
140 {'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 +0530141 {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
142 {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
143 {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
144 {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530145
146 # supplier type
Rushabh Mehtaad714732013-07-10 18:59:55 +0530147 {'doctype': 'Supplier Type', 'supplier_type': 'Services'},
148 {'doctype': 'Supplier Type', 'supplier_type': 'Local'},
149 {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
150 {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
151 {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
152 {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
153 {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530154
155 # Sales Person
Rushabh Mehtaad714732013-07-10 18:59:55 +0530156 {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530157
158 # UOM
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530159 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
160 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530161 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530162 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
163 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
164 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
165 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530166 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530167 ]
168
Anand Doshi4ee647e2013-07-08 18:50:45 +0530169 from webnotes.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530170 for r in records:
Rushabh Mehtae41bceb2013-07-10 20:42:44 +0530171 bean = webnotes.bean(r)
172
173 # ignore mandatory for root
174 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
175 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
176 bean.ignore_mandatory = True
177
178 bean.insert()