Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
| 2 | |
| 3 | import webnotes |
| 4 | |
| 5 | def pre_import(): |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 6 | webnotes.conn.begin() |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 7 | make_modules() |
| 8 | make_roles() |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 9 | webnotes.conn.commit() |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 10 | webnotes.reload_doc("utilities", "doctype", "gl_mapper") |
| 11 | webnotes.reload_doc("utilities", "doctype", "gl_mapper_detail") |
| 12 | |
| 13 | def make_modules(): |
| 14 | modules = [ |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 15 | " Home", " System", " Utilities", " Website", " Setup", |
| 16 | " Selling", " Buying", " Projects", " Accounts", " Stock", |
| 17 | " Support", " HR", " Manufacturing"] |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 18 | |
| 19 | for m in modules: |
| 20 | doc = webnotes.doc(fielddata = { |
| 21 | "doctype": "Module Def", |
| 22 | "module_name": m, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 23 | }) |
| 24 | doc.insert() |
| 25 | |
| 26 | def make_roles(): |
| 27 | roles = [ |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 28 | "Accounts Manager", "Accounts User", "Analytics", "Auditor", |
| 29 | "Blogger", "Customer", "Employee", "Expense Approver", |
| 30 | "HR Manager", "HR User", "Leave Approver", "Maintenance Manager", |
| 31 | "Maintenance User", "Manufacturing Manager", "Manufacturing User", |
| 32 | "Material Manager", "Material Master Manager", "Material User", |
Rushabh Mehta | ed19666 | 2013-02-26 16:36:41 +0530 | [diff] [blame] | 33 | "Partner", "Projects User", "Projects Manager", "Purchase Manager", "Purchase Master Manager", |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 34 | "Purchase User", "Quality Manager", "Sales Manager", |
| 35 | "Sales Master Manager", "Sales User", "Supplier", "Support Manager", |
Anand Doshi | 3422bdf | 2013-02-12 13:03:25 +0530 | [diff] [blame] | 36 | "Support Team", "Website Manager"] |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 37 | |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 38 | for r in roles: |
| 39 | doc = webnotes.doc(fielddata = { |
| 40 | "doctype":"Role", |
| 41 | "role_name": r |
| 42 | }) |
| 43 | doc.insert() |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 44 | |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 45 | def post_import(): |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 46 | webnotes.conn.begin() |
| 47 | # feature setup |
| 48 | import_defaults() |
| 49 | import_country_and_currency() |
| 50 | |
| 51 | # home page |
| 52 | webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop') |
| 53 | |
| 54 | # features |
| 55 | feature_setup() |
| 56 | |
| 57 | # all roles to Administrator |
| 58 | from setup.doctype.setup_control.setup_control import add_all_roles_to |
| 59 | add_all_roles_to("Administrator") |
| 60 | |
| 61 | webnotes.conn.commit() |
| 62 | |
| 63 | def feature_setup(): |
| 64 | """save global defaults and features setup""" |
| 65 | doc = webnotes.doc("Features Setup", "Features Setup") |
| 66 | |
| 67 | # store value as 1 for all these fields |
| 68 | flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode', |
| 69 | 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details', |
| 70 | 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts', |
| 71 | 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras', |
| 72 | 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality', |
| 73 | 'fs_page_break', 'fs_more_info' |
| 74 | ] |
| 75 | doc.fields.update(dict(zip(flds, [1]*len(flds)))) |
| 76 | doc.save() |
| 77 | |
| 78 | def import_country_and_currency(): |
| 79 | from webnotes.country_info import get_all |
| 80 | data = get_all() |
Anand Doshi | 44077d2 | 2013-01-27 17:02:49 +0530 | [diff] [blame] | 81 | |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 82 | for name in data: |
| 83 | country = webnotes._dict(data[name]) |
| 84 | webnotes.doc({ |
| 85 | "doctype": "Country", |
| 86 | "country_name": name, |
| 87 | "date_format": country.date_format or "dd-mm-yyyy", |
| 88 | "time_zones": "\n".join(country.timezones or []) |
| 89 | }).insert() |
| 90 | |
Anand Doshi | 44077d2 | 2013-01-27 17:02:49 +0530 | [diff] [blame] | 91 | if country.currency and not webnotes.conn.exists("Currency", country.currency): |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 92 | webnotes.doc({ |
| 93 | "doctype": "Currency", |
| 94 | "currency_name": country.currency, |
| 95 | "fraction": country.currency_fraction, |
| 96 | "symbol": country.currency_symbol, |
Rushabh Mehta | f5b04cf | 2013-01-21 10:14:10 +0530 | [diff] [blame] | 97 | "fraction_units": country.currency_fraction_units, |
| 98 | "number_format": country.number_format |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 99 | }).insert() |
| 100 | |
| 101 | def import_defaults(): |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 102 | records = [ |
| 103 | # item group |
| 104 | {'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'name': 'All Item Groups', 'parent_item_group': ''}, |
| 105 | {'doctype': 'Item Group', 'item_group_name': 'Default', 'is_group': 'No', 'name': 'Default', 'parent_item_group': 'All Item Groups'}, |
| 106 | |
| 107 | # deduction type |
| 108 | {'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'}, |
| 109 | {'doctype': 'Deduction Type', 'name': 'Professional Tax', 'description': 'Professional Tax', 'deduction_name': 'Professional Tax'}, |
| 110 | {'doctype': 'Deduction Type', 'name': 'Provident Fund', 'description': 'Provident fund', 'deduction_name': 'Provident Fund'}, |
| 111 | |
| 112 | # earning type |
| 113 | {'doctype': 'Earning Type', 'name': 'Basic', 'description': 'Basic', 'earning_name': 'Basic', 'taxable': 'Yes'}, |
| 114 | {'doctype': 'Earning Type', 'name': 'House Rent Allowance', 'description': 'House Rent Allowance', 'earning_name': 'House Rent Allowance', 'taxable': 'No'}, |
| 115 | |
| 116 | # expense claim type |
| 117 | {'doctype': 'Expense Claim Type', 'name': 'Calls', 'expense_type': 'Calls'}, |
| 118 | {'doctype': 'Expense Claim Type', 'name': 'Food', 'expense_type': 'Food'}, |
| 119 | {'doctype': 'Expense Claim Type', 'name': 'Medical', 'expense_type': 'Medical'}, |
| 120 | {'doctype': 'Expense Claim Type', 'name': 'Others', 'expense_type': 'Others'}, |
| 121 | {'doctype': 'Expense Claim Type', 'name': 'Travel', 'expense_type': 'Travel'}, |
| 122 | |
| 123 | # leave type |
| 124 | {'doctype': 'Leave Type', 'leave_type_name': 'Casual Leave', 'name': 'Casual Leave', 'is_encash': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', }, |
| 125 | {'doctype': 'Leave Type', 'leave_type_name': 'Compensatory Off', 'name': 'Compensatory Off', 'is_encash': 0, 'is_carry_forward': 0, }, |
| 126 | {'doctype': 'Leave Type', 'leave_type_name': 'Sick Leave', 'name': 'Sick Leave', 'is_encash': 0, 'is_carry_forward': 0, }, |
| 127 | {'doctype': 'Leave Type', 'leave_type_name': 'Privilege Leave', 'name': 'Privilege Leave', 'is_encash': 0, 'is_carry_forward': 0, }, |
| 128 | {'doctype': 'Leave Type', 'leave_type_name': 'Leave Without Pay', 'name': 'Leave Without Pay', 'is_encash': 0, 'is_carry_forward': 0, 'is_lwp':1}, |
| 129 | |
| 130 | # territory |
| 131 | {'doctype': 'Territory', 'territory_name': 'All Territories', 'is_group': 'Yes', 'name': 'All Territories', 'parent_territory': ''}, |
| 132 | {'doctype': 'Territory', 'territory_name': 'Default', 'is_group': 'No', 'name': 'Default', 'parent_territory': 'All Territories'}, |
| 133 | |
| 134 | # customer group |
| 135 | {'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''}, |
| 136 | {'doctype': 'Customer Group', 'customer_group_name': 'Default Customer Group', 'is_group': 'No', 'name': 'Default Customer Group', 'parent_customer_group': 'All Customer Groups'}, |
| 137 | |
| 138 | # supplier type |
| 139 | {'doctype': 'Supplier Type', 'name': 'Default Supplier Type', 'supplier_type': 'Default Supplier Type'}, |
| 140 | |
| 141 | # Price List |
| 142 | {'doctype': 'Price List', 'name': 'Default Price List', 'price_list_name': 'Default Price List'}, |
| 143 | {'doctype': 'Price List', 'name': 'Standard', 'price_list_name': 'Standard'}, |
| 144 | |
| 145 | # warehouse type |
| 146 | {'doctype': 'Warehouse Type', 'name': 'Default Warehouse Type', 'warehouse_type': 'Default Warehouse Type'}, |
| 147 | {'doctype': 'Warehouse Type', 'name': 'Fixed Asset', 'warehouse_type': 'Fixed Asset'}, |
| 148 | {'doctype': 'Warehouse Type', 'name': 'Reserved', 'warehouse_type': 'Reserved'}, |
| 149 | {'doctype': 'Warehouse Type', 'name': 'Rejected', 'warehouse_type': 'Rejected'}, |
| 150 | {'doctype': 'Warehouse Type', 'name': 'Sample', 'warehouse_type': 'Sample'}, |
| 151 | {'doctype': 'Warehouse Type', 'name': 'Stores', 'warehouse_type': 'Stores'}, |
| 152 | {'doctype': 'Warehouse Type', 'name': 'WIP Warehouse', 'warehouse_type': 'WIP Warehouse'}, |
| 153 | |
| 154 | # warehouse |
| 155 | {'doctype': 'Warehouse', 'warehouse_name': 'Default Warehouse', 'name': 'Default Warehouse', 'warehouse_type': 'Default Warehouse Type'}, |
| 156 | |
| 157 | # Workstation |
| 158 | {'doctype': 'Workstation', 'name': 'Default Workstation', 'workstation_name': 'Default Workstation', 'warehouse': 'Default Warehouse'}, |
| 159 | |
| 160 | # Sales Person |
| 161 | {'doctype': 'Sales Person', 'name': 'All Sales Persons', 'sales_person_name': 'All Sales Persons', 'is_group': "Yes", "parent_sales_person": ""}, |
| 162 | |
| 163 | # UOM |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 164 | {'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit'}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 165 | {'uom_name': 'Box', 'doctype': 'UOM', 'name': 'Box'}, |
| 166 | {'uom_name': 'Ft', 'doctype': 'UOM', 'name': 'Ft'}, |
| 167 | {'uom_name': 'Kg', 'doctype': 'UOM', 'name': 'Kg'}, |
| 168 | {'uom_name': 'Ltr', 'doctype': 'UOM', 'name': 'Ltr'}, |
| 169 | {'uom_name': 'Meter', 'doctype': 'UOM', 'name': 'Meter'}, |
| 170 | {'uom_name': 'Mtr', 'doctype': 'UOM', 'name': 'Mtr'}, |
| 171 | {'uom_name': 'Nos', 'doctype': 'UOM', 'name': 'Nos'}, |
| 172 | {'uom_name': 'Pair', 'doctype': 'UOM', 'name': 'Pair'}, |
| 173 | {'uom_name': 'Set', 'doctype': 'UOM', 'name': 'Set'}, |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 174 | {'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'}, |
| 175 | {'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'}, |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 176 | ] |
| 177 | |
| 178 | for r in records: |
| 179 | doc = webnotes.doc(r) |
| 180 | doc.insert() |
| 181 | |