blob: 83606e0f596677b7b3373829a7f505479e52669e [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"""
29 doc = webnotes.doc("Features Setup", "Features Setup")
30
31 # store value as 1 for all these fields
32 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
33 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
34 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
35 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
36 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
Rushabh Mehta16a62fa2013-08-23 13:16:22 +053037 'fs_page_break', 'fs_more_info', 'fs_pos_view'
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053038 ]
39 doc.fields.update(dict(zip(flds, [1]*len(flds))))
40 doc.save()
41
42def import_country_and_currency():
43 from webnotes.country_info import get_all
44 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053045
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053046 for name in data:
47 country = webnotes._dict(data[name])
48 webnotes.doc({
49 "doctype": "Country",
50 "country_name": name,
51 "date_format": country.date_format or "dd-mm-yyyy",
52 "time_zones": "\n".join(country.timezones or [])
53 }).insert()
54
Anand Doshi44077d22013-01-27 17:02:49 +053055 if country.currency and not webnotes.conn.exists("Currency", country.currency):
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053056 webnotes.doc({
57 "doctype": "Currency",
58 "currency_name": country.currency,
59 "fraction": country.currency_fraction,
60 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +053061 "fraction_units": country.currency_fraction_units,
62 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053063 }).insert()
64
65def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053066 records = [
67 # item group
Rushabh Mehtaad714732013-07-10 18:59:55 +053068 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
69 {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
70 {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
71 {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053072 {'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053073
74 # deduction type
75 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
76 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
77 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
78
79 # earning type
80 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
81 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
82
83 # expense claim type
84 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
85 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
86 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
87 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
88 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
89
90 # leave type
91 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
92 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
93 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
94 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
95 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
96
97 # territory
98 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053099
100 # customer group
101 {'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 +0530102 {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
103 {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
104 {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
105 {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530106
107 # supplier type
Rushabh Mehtaad714732013-07-10 18:59:55 +0530108 {'doctype': 'Supplier Type', 'supplier_type': 'Services'},
109 {'doctype': 'Supplier Type', 'supplier_type': 'Local'},
110 {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
111 {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
112 {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
113 {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
114 {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530115
116 # Sales Person
Rushabh Mehtaad714732013-07-10 18:59:55 +0530117 {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530118
119 # UOM
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530120 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
121 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530122 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
Rushabh Mehta4dca4012013-07-25 17:45:59 +0530123 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
124 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
125 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
126 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530127 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530128 ]
129
Anand Doshi4ee647e2013-07-08 18:50:45 +0530130 from webnotes.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530131 for r in records:
Rushabh Mehtae41bceb2013-07-10 20:42:44 +0530132 bean = webnotes.bean(r)
133
134 # ignore mandatory for root
135 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
136 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
137 bean.ignore_mandatory = True
138
139 bean.insert()