blob: d79559426bea93a03049e939a1d0f36edb66822e [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
Rushabh Mehta6f9915c2013-01-16 17:48:17 +05308def post_import():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +05309 webnotes.conn.begin()
Rushabh Mehtaa94d1af2013-06-25 12:36:13 +053010
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053011 # feature setup
12 import_defaults()
13 import_country_and_currency()
14
15 # home page
16 webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')
17
18 # features
19 feature_setup()
20
21 # all roles to Administrator
22 from setup.doctype.setup_control.setup_control import add_all_roles_to
23 add_all_roles_to("Administrator")
24
25 webnotes.conn.commit()
26
27def feature_setup():
28 """save global defaults and features setup"""
Anand Doshia29b76f2013-09-13 17:42:03 +053029 bean = webnotes.bean("Features Setup", "Features Setup")
30 bean.ignore_permissions = True
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053031
32 # store value as 1 for all these fields
33 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
34 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
35 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
36 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
37 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
Rushabh Mehta16a62fa2013-08-23 13:16:22 +053038 'fs_page_break', 'fs_more_info', 'fs_pos_view'
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053039 ]
Anand Doshia29b76f2013-09-13 17:42:03 +053040 bean.doc.fields.update(dict(zip(flds, [1]*len(flds))))
41 bean.save()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053042
43def import_country_and_currency():
44 from webnotes.country_info import get_all
45 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053046
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053047 for name in data:
48 country = webnotes._dict(data[name])
49 webnotes.doc({
50 "doctype": "Country",
51 "country_name": name,
52 "date_format": country.date_format or "dd-mm-yyyy",
53 "time_zones": "\n".join(country.timezones or [])
54 }).insert()
55
Anand Doshi44077d22013-01-27 17:02:49 +053056 if country.currency and not webnotes.conn.exists("Currency", country.currency):
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053057 webnotes.doc({
58 "doctype": "Currency",
59 "currency_name": country.currency,
60 "fraction": country.currency_fraction,
61 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +053062 "fraction_units": country.currency_fraction_units,
63 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053064 }).insert()
65
66def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053067 records = [
68 # item group
Rushabh Mehtaad714732013-07-10 18:59:55 +053069 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
70 {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
71 {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
72 {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053073 {'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053074
75 # deduction type
76 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
77 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
78 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
79
80 # earning type
81 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
82 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
83
84 # expense claim type
85 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
86 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
87 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
88 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
89 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
90
91 # leave type
92 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
93 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
94 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
95 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
96 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
97
98 # territory
99 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530100
101 # customer group
102 {'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 +0530103 {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
104 {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
105 {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
106 {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530107
108 # supplier type
Rushabh Mehtaad714732013-07-10 18:59:55 +0530109 {'doctype': 'Supplier Type', 'supplier_type': 'Services'},
110 {'doctype': 'Supplier Type', 'supplier_type': 'Local'},
111 {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
112 {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
113 {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
114 {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
115 {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530116
117 # Sales Person
Rushabh Mehtaad714732013-07-10 18:59:55 +0530118 {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530119
120 # UOM
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530121 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
122 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530123 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530124 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
125 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
126 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
127 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530128 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530129 ]
130
Anand Doshi4ee647e2013-07-08 18:50:45 +0530131 from webnotes.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530132 for r in records:
Rushabh Mehtae41bceb2013-07-10 20:42:44 +0530133 bean = webnotes.bean(r)
134
135 # ignore mandatory for root
136 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
137 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
138 bean.ignore_mandatory = True
139
140 bean.insert()