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 | |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 6 | import frappe |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 7 | |
Rushabh Mehta | 370a024 | 2014-04-18 16:00:41 +0530 | [diff] [blame] | 8 | from frappe import _ |
| 9 | |
Anand Doshi | 56198f4 | 2014-06-26 12:47:45 +0530 | [diff] [blame] | 10 | default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via |
Anand Doshi | 7f41ff2 | 2014-06-26 12:02:55 +0530 | [diff] [blame] | 11 | <a style="color: #888" href="http://erpnext.org">ERPNext</a></div>""" |
| 12 | |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame] | 13 | def after_install(): |
Rushabh Mehta | 40b2b03 | 2014-04-21 13:43:11 +0530 | [diff] [blame] | 14 | frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert() |
Rushabh Mehta | 33003c6 | 2014-04-30 11:16:02 +0530 | [diff] [blame] | 15 | set_single_defaults() |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 16 | import_country_and_currency() |
Nabin Hait | 813a93d | 2014-03-06 18:21:56 +0530 | [diff] [blame] | 17 | from erpnext.accounts.doctype.chart_of_accounts.import_charts import import_charts |
| 18 | import_charts() |
Rushabh Mehta | 558a9aa | 2014-04-04 12:00:36 +0530 | [diff] [blame] | 19 | frappe.db.set_default('desktop: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") |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 23 | frappe.db.commit() |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 24 | |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 25 | def import_country_and_currency(): |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 26 | from frappe.country_info import get_all |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 27 | data = get_all() |
Anand Doshi | 13ae548 | 2014-04-10 18:40:57 +0530 | [diff] [blame] | 28 | |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 29 | for name in data: |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 30 | country = frappe._dict(data[name]) |
Anand Doshi | 7fbdba0 | 2014-03-25 13:50:52 +0530 | [diff] [blame] | 31 | if not frappe.db.exists("Country", name): |
Rushabh Mehta | b385ecf | 2014-03-28 16:44:37 +0530 | [diff] [blame] | 32 | frappe.get_doc({ |
Anand Doshi | 7fbdba0 | 2014-03-25 13:50:52 +0530 | [diff] [blame] | 33 | "doctype": "Country", |
| 34 | "country_name": name, |
| 35 | "code": country.code, |
| 36 | "date_format": country.date_format or "dd-mm-yyyy", |
| 37 | "time_zones": "\n".join(country.timezones or []) |
| 38 | }).insert() |
Anand Doshi | 13ae548 | 2014-04-10 18:40:57 +0530 | [diff] [blame] | 39 | |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 40 | if country.currency and not frappe.db.exists("Currency", country.currency): |
Rushabh Mehta | b385ecf | 2014-03-28 16:44:37 +0530 | [diff] [blame] | 41 | frappe.get_doc({ |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 42 | "doctype": "Currency", |
| 43 | "currency_name": country.currency, |
| 44 | "fraction": country.currency_fraction, |
| 45 | "symbol": country.currency_symbol, |
Rushabh Mehta | f5b04cf | 2013-01-21 10:14:10 +0530 | [diff] [blame] | 46 | "fraction_units": country.currency_fraction_units, |
| 47 | "number_format": country.number_format |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 48 | }).insert() |
| 49 | |
Anand Doshi | de560aa | 2014-05-06 12:02:23 +0530 | [diff] [blame] | 50 | # enable frequently used currencies |
| 51 | for currency in ("INR", "USD", "GBP", "EUR", "AED", "AUD", "JPY", "CNY", "CHF"): |
| 52 | frappe.db.set_value("Currency", currency, "enabled", 1) |
| 53 | |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame] | 54 | def feature_setup(): |
| 55 | """save global defaults and features setup""" |
Rushabh Mehta | f191f85 | 2014-04-02 18:09:34 +0530 | [diff] [blame] | 56 | doc = frappe.get_doc("Features Setup", "Features Setup") |
| 57 | doc.ignore_permissions = True |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame] | 58 | |
| 59 | # store value as 1 for all these fields |
| 60 | flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode', |
| 61 | 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details', |
| 62 | 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts', |
| 63 | 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras', |
| 64 | 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality', |
| 65 | 'fs_page_break', 'fs_more_info', 'fs_pos_view' |
| 66 | ] |
Rushabh Mehta | d21f55b | 2014-04-29 16:24:37 +0530 | [diff] [blame] | 67 | for f in flds: |
| 68 | doc.set(f, 1) |
Rushabh Mehta | f191f85 | 2014-04-02 18:09:34 +0530 | [diff] [blame] | 69 | doc.save() |
Pratik Vyas | 28da752 | 2014-02-19 20:53:45 +0530 | [diff] [blame] | 70 | |
| 71 | def set_single_defaults(): |
Nabin Hait | e7885e3 | 2014-04-04 13:26:50 +0530 | [diff] [blame] | 72 | for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""): |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 73 | default_values = frappe.db.sql("""select fieldname, `default` from `tabDocField` |
Rushabh Mehta | f14b809 | 2014-04-03 14:30:42 +0530 | [diff] [blame] | 74 | where parent=%s""", dt) |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 75 | if default_values: |
| 76 | try: |
Rushabh Mehta | b385ecf | 2014-03-28 16:44:37 +0530 | [diff] [blame] | 77 | b = frappe.get_doc(dt, dt) |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 78 | for fieldname, value in default_values: |
Anand Doshi | f78d1ae | 2014-03-28 13:55:00 +0530 | [diff] [blame] | 79 | b.set(fieldname, value) |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 80 | b.save() |
| 81 | except frappe.MandatoryError: |
| 82 | pass |
| 83 | |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 84 | frappe.db.set_default("date_format", "dd-mm-yyyy") |
Anand Doshi | 7f41ff2 | 2014-06-26 12:02:55 +0530 | [diff] [blame] | 85 | |
Anand Doshi | 56198f4 | 2014-06-26 12:47:45 +0530 | [diff] [blame] | 86 | frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", |
| 87 | default_mail_footer) |