blob: d65582b8170d223c7e74bd4188a4641b000519f6 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt
3
Rushabh Mehta6f9915c2013-01-16 17:48:17 +05304from __future__ import unicode_literals
5
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05306import frappe
Rushabh Mehta6f9915c2013-01-16 17:48:17 +05307
Rushabh Mehta1f847992013-12-12 19:12:19 +05308def after_install():
Rushabh Mehtadb7139a2013-01-17 18:22:22 +05309 import_defaults()
10 import_country_and_currency()
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053011 frappe.conn.set_value('Control Panel', None, 'home_page', 'setup-wizard')
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053012 feature_setup()
Rushabh Mehta1f847992013-12-12 19:12:19 +053013 from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053014 add_all_roles_to("Administrator")
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053015 frappe.conn.commit()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053016
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053017def import_country_and_currency():
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053018 from frappe.country_info import get_all
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053019 data = get_all()
Anand Doshi44077d22013-01-27 17:02:49 +053020
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053021 for name in data:
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053022 country = frappe._dict(data[name])
23 frappe.doc({
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053024 "doctype": "Country",
25 "country_name": name,
26 "date_format": country.date_format or "dd-mm-yyyy",
27 "time_zones": "\n".join(country.timezones or [])
28 }).insert()
29
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053030 if country.currency and not frappe.conn.exists("Currency", country.currency):
31 frappe.doc({
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053032 "doctype": "Currency",
33 "currency_name": country.currency,
34 "fraction": country.currency_fraction,
35 "symbol": country.currency_symbol,
Rushabh Mehtaf5b04cf2013-01-21 10:14:10 +053036 "fraction_units": country.currency_fraction_units,
37 "number_format": country.number_format
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053038 }).insert()
39
40def import_defaults():
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053041 records = [
42 # item group
Rushabh Mehtaad714732013-07-10 18:59:55 +053043 {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
44 {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
45 {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
46 {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta7cfefbc2013-08-07 17:46:35 +053047 {'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehtaddca90e2013-10-09 16:08:54 +053048 {'doctype': 'Item Group', 'item_group_name': 'Consumable', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053049
50 # deduction type
51 {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
52 {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'},
53 {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'},
54
55 # earning type
56 {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'},
57 {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'},
58
59 # expense claim type
60 {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'},
61 {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'},
62 {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'},
63 {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'},
64 {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'},
65
66 # leave type
67 {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', },
68 {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, },
69 {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, },
70 {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, },
71 {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1},
72
73 # territory
74 {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053075
76 # customer group
77 {'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 +053078 {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
79 {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
80 {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
81 {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053082
83 # supplier type
Rushabh Mehtaad714732013-07-10 18:59:55 +053084 {'doctype': 'Supplier Type', 'supplier_type': 'Services'},
85 {'doctype': 'Supplier Type', 'supplier_type': 'Local'},
86 {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
87 {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
88 {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
89 {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
90 {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053091
92 # Sales Person
Rushabh Mehtaad714732013-07-10 18:59:55 +053093 {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053094
95 # UOM
Rushabh Mehta4dca4012013-07-25 17:45:59 +053096 {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1},
97 {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +053098 {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'},
Rushabh Mehta4dca4012013-07-25 17:45:59 +053099 {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1},
100 {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1},
101 {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1},
102 {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'},
Rushabh Mehtadb7139a2013-01-17 18:22:22 +0530103 {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'},
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530104 ]
105
Rushabh Mehta793ba6b2014-02-14 15:47:51 +0530106 from frappe.modules import scrub
Rushabh Mehta6f9915c2013-01-16 17:48:17 +0530107 for r in records:
Rushabh Mehta793ba6b2014-02-14 15:47:51 +0530108 bean = frappe.bean(r)
Rushabh Mehtae41bceb2013-07-10 20:42:44 +0530109
110 # ignore mandatory for root
111 parent_link_field = ("parent_" + scrub(bean.doc.doctype))
112 if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
113 bean.ignore_mandatory = True
114
Rushabh Mehta1f847992013-12-12 19:12:19 +0530115 bean.insert()
116
117def feature_setup():
118 """save global defaults and features setup"""
Rushabh Mehta793ba6b2014-02-14 15:47:51 +0530119 bean = frappe.bean("Features Setup", "Features Setup")
Rushabh Mehta1f847992013-12-12 19:12:19 +0530120 bean.ignore_permissions = True
121
122 # store value as 1 for all these fields
123 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
124 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
125 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
126 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
127 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
128 'fs_page_break', 'fs_more_info', 'fs_pos_view'
129 ]
130 bean.doc.fields.update(dict(zip(flds, [1]*len(flds))))
Rushabh Mehtab63d5502013-12-23 16:09:00 +0530131 bean.save()