Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 4 | from __future__ import unicode_literals |
| 5 | |
| 6 | import webnotes |
| 7 | |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame^] | 8 | def get_hooks(): |
| 9 | return { |
| 10 | "app_include_js": ["assets/js/erpnext.min.js"], |
| 11 | "app_include_css": ["assets/css/erpnext.css"], |
| 12 | "desktop_icons": get_desktop_icons(), |
| 13 | "boot_session": ["erpnext.startup.boot.boot_session"] |
| 14 | } |
Rushabh Mehta | a94d1af | 2013-06-25 12:36:13 +0530 | [diff] [blame] | 15 | |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame^] | 16 | def after_install(): |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 17 | import_defaults() |
| 18 | import_country_and_currency() |
Rushabh Mehta | 8c5a5f1 | 2013-10-08 17:59:11 +0530 | [diff] [blame] | 19 | webnotes.conn.set_value('Control Panel', None, 'home_page', 'setup-wizard') |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 20 | feature_setup() |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame^] | 21 | from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 22 | add_all_roles_to("Administrator") |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 23 | webnotes.conn.commit() |
| 24 | |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 25 | def import_country_and_currency(): |
| 26 | from webnotes.country_info import get_all |
| 27 | data = get_all() |
Anand Doshi | 44077d2 | 2013-01-27 17:02:49 +0530 | [diff] [blame] | 28 | |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 29 | for name in data: |
| 30 | country = webnotes._dict(data[name]) |
| 31 | webnotes.doc({ |
| 32 | "doctype": "Country", |
| 33 | "country_name": name, |
| 34 | "date_format": country.date_format or "dd-mm-yyyy", |
| 35 | "time_zones": "\n".join(country.timezones or []) |
| 36 | }).insert() |
| 37 | |
Anand Doshi | 44077d2 | 2013-01-27 17:02:49 +0530 | [diff] [blame] | 38 | if country.currency and not webnotes.conn.exists("Currency", country.currency): |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 39 | webnotes.doc({ |
| 40 | "doctype": "Currency", |
| 41 | "currency_name": country.currency, |
| 42 | "fraction": country.currency_fraction, |
| 43 | "symbol": country.currency_symbol, |
Rushabh Mehta | f5b04cf | 2013-01-21 10:14:10 +0530 | [diff] [blame] | 44 | "fraction_units": country.currency_fraction_units, |
| 45 | "number_format": country.number_format |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 46 | }).insert() |
| 47 | |
| 48 | def import_defaults(): |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 49 | records = [ |
| 50 | # item group |
Rushabh Mehta | ad71473 | 2013-07-10 18:59:55 +0530 | [diff] [blame] | 51 | {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''}, |
| 52 | {'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'}, |
| 53 | {'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'}, |
| 54 | {'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'}, |
Rushabh Mehta | 7cfefbc | 2013-08-07 17:46:35 +0530 | [diff] [blame] | 55 | {'doctype': 'Item Group', 'item_group_name': 'Sub Assemblies', 'is_group': 'No', 'parent_item_group': 'All Item Groups'}, |
Rushabh Mehta | ddca90e | 2013-10-09 16:08:54 +0530 | [diff] [blame] | 56 | {'doctype': 'Item Group', 'item_group_name': 'Consumable', 'is_group': 'No', 'parent_item_group': 'All Item Groups'}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 57 | |
| 58 | # deduction type |
| 59 | {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'}, |
| 60 | {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'}, |
| 61 | {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'}, |
| 62 | |
| 63 | # earning type |
| 64 | {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'}, |
| 65 | {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'}, |
| 66 | |
| 67 | # expense claim type |
| 68 | {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'}, |
| 69 | {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'}, |
| 70 | {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'}, |
| 71 | {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'}, |
| 72 | {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'}, |
| 73 | |
| 74 | # leave type |
| 75 | {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', }, |
| 76 | {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, }, |
| 77 | {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, }, |
| 78 | {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, }, |
| 79 | {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1}, |
| 80 | |
| 81 | # territory |
| 82 | {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 83 | |
| 84 | # customer group |
| 85 | {'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''}, |
Rushabh Mehta | ad71473 | 2013-07-10 18:59:55 +0530 | [diff] [blame] | 86 | {'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'}, |
| 87 | {'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'}, |
| 88 | {'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'}, |
| 89 | {'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 90 | |
| 91 | # supplier type |
Rushabh Mehta | ad71473 | 2013-07-10 18:59:55 +0530 | [diff] [blame] | 92 | {'doctype': 'Supplier Type', 'supplier_type': 'Services'}, |
| 93 | {'doctype': 'Supplier Type', 'supplier_type': 'Local'}, |
| 94 | {'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'}, |
| 95 | {'doctype': 'Supplier Type', 'supplier_type': 'Electrical'}, |
| 96 | {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'}, |
| 97 | {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'}, |
| 98 | {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 99 | |
| 100 | # Sales Person |
Rushabh Mehta | ad71473 | 2013-07-10 18:59:55 +0530 | [diff] [blame] | 101 | {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 102 | |
| 103 | # UOM |
Rushabh Mehta | 4dca401 | 2013-07-25 17:45:59 +0530 | [diff] [blame] | 104 | {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit', "must_be_whole_number": 1}, |
| 105 | {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box', "must_be_whole_number": 1}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 106 | {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'}, |
Rushabh Mehta | 4dca401 | 2013-07-25 17:45:59 +0530 | [diff] [blame] | 107 | {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos', "must_be_whole_number": 1}, |
| 108 | {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair', "must_be_whole_number": 1}, |
| 109 | {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set', "must_be_whole_number": 1}, |
| 110 | {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'}, |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 111 | {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 112 | ] |
| 113 | |
Anand Doshi | 4ee647e | 2013-07-08 18:50:45 +0530 | [diff] [blame] | 114 | from webnotes.modules import scrub |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 115 | for r in records: |
Rushabh Mehta | e41bceb | 2013-07-10 20:42:44 +0530 | [diff] [blame] | 116 | bean = webnotes.bean(r) |
| 117 | |
| 118 | # ignore mandatory for root |
| 119 | parent_link_field = ("parent_" + scrub(bean.doc.doctype)) |
| 120 | if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field): |
| 121 | bean.ignore_mandatory = True |
| 122 | |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame^] | 123 | bean.insert() |
| 124 | |
| 125 | def feature_setup(): |
| 126 | """save global defaults and features setup""" |
| 127 | bean = webnotes.bean("Features Setup", "Features Setup") |
| 128 | bean.ignore_permissions = True |
| 129 | |
| 130 | # store value as 1 for all these fields |
| 131 | flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode', |
| 132 | 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details', |
| 133 | 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts', |
| 134 | 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras', |
| 135 | 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality', |
| 136 | 'fs_page_break', 'fs_more_info', 'fs_pos_view' |
| 137 | ] |
| 138 | bean.doc.fields.update(dict(zip(flds, [1]*len(flds)))) |
| 139 | bean.save() |
| 140 | |
| 141 | def get_desktop_icons(): |
| 142 | return { |
| 143 | "Accounts": { |
| 144 | "color": "#3498db", |
| 145 | "icon": "icon-money", |
| 146 | "link": "accounts-home", |
| 147 | "type": "module" |
| 148 | }, |
| 149 | "Activity": { |
| 150 | "color": "#e67e22", |
| 151 | "icon": "icon-play", |
| 152 | "label": "Activity", |
| 153 | "link": "activity", |
| 154 | "type": "page" |
| 155 | }, |
| 156 | "Buying": { |
| 157 | "color": "#c0392b", |
| 158 | "icon": "icon-shopping-cart", |
| 159 | "link": "buying-home", |
| 160 | "type": "module" |
| 161 | }, |
| 162 | "HR": { |
| 163 | "color": "#2ecc71", |
| 164 | "icon": "icon-group", |
| 165 | "label": "Human Resources", |
| 166 | "link": "hr-home", |
| 167 | "type": "module" |
| 168 | }, |
| 169 | "Manufacturing": { |
| 170 | "color": "#7f8c8d", |
| 171 | "icon": "icon-cogs", |
| 172 | "link": "manufacturing-home", |
| 173 | "type": "module" |
| 174 | }, |
| 175 | "Notes": { |
| 176 | "color": "#95a5a6", |
| 177 | "doctype": "Note", |
| 178 | "icon": "icon-file-alt", |
| 179 | "label": "Notes", |
| 180 | "link": "List/Note", |
| 181 | "type": "list" |
| 182 | }, |
| 183 | "Projects": { |
| 184 | "color": "#8e44ad", |
| 185 | "icon": "icon-puzzle-piece", |
| 186 | "link": "projects-home", |
| 187 | "type": "module" |
| 188 | }, |
| 189 | "Selling": { |
| 190 | "color": "#1abc9c", |
| 191 | "icon": "icon-tag", |
| 192 | "link": "selling-home", |
| 193 | "type": "module" |
| 194 | }, |
| 195 | "Setup": { |
| 196 | "color": "#bdc3c7", |
| 197 | "icon": "icon-wrench", |
| 198 | "link": "Setup", |
| 199 | "type": "setup" |
| 200 | }, |
| 201 | "Stock": { |
| 202 | "color": "#f39c12", |
| 203 | "icon": "icon-truck", |
| 204 | "link": "stock-home", |
| 205 | "type": "module" |
| 206 | }, |
| 207 | "Support": { |
| 208 | "color": "#2c3e50", |
| 209 | "icon": "icon-phone", |
| 210 | "link": "support-home", |
| 211 | "type": "module" |
| 212 | } |
| 213 | } |