blob: d218793ee04faf05d979ab857ac62cab1a15249d [file] [log] [blame]
Anand Doshi885e0742015-03-03 14:55:30 +05301# Copyright (c) 2015, Frappe 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
Anand Doshi56198f42014-06-26 12:47:45 +05308default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
Anand Doshi7f41ff22014-06-26 12:02:55 +05309 <a style="color: #888" href="http://erpnext.org">ERPNext</a></div>"""
10
Rushabh Mehta1f847992013-12-12 19:12:19 +053011def after_install():
Rushabh Mehta40b2b032014-04-21 13:43:11 +053012 frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
Rushabh Mehta33003c62014-04-30 11:16:02 +053013 set_single_defaults()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053014 feature_setup()
Neil Trini Lasrado3c0d5cb2016-02-24 15:58:25 +053015 from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053016 add_all_roles_to("Administrator")
Rushabh Mehtaa33d4682015-06-01 17:15:42 +053017 add_web_forms()
Anand Doshie9baaa62014-02-26 12:35:33 +053018 frappe.db.commit()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053019
Rushabh Mehtad55bdcf2015-12-31 11:12:48 +053020def check_setup_wizard_not_completed():
21 if frappe.db.get_default('desktop:home_page') == 'desktop':
22 print
23 print "ERPNext can only be installed on a fresh site where the setup wizard is not completed"
24 print "You can reinstall this site (after saving your data) using: bench --site [sitename] reinstall"
25 print
26 return False
27
Rushabh Mehta1f847992013-12-12 19:12:19 +053028def feature_setup():
29 """save global defaults and features setup"""
Rushabh Mehtaf191f852014-04-02 18:09:34 +053030 doc = frappe.get_doc("Features Setup", "Features Setup")
Anand Doshi6dfd4302015-02-10 14:41:27 +053031 doc.flags.ignore_permissions = True
Rushabh Mehta1f847992013-12-12 19:12:19 +053032
33 # store value as 1 for all these fields
34 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
35 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
36 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
37 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
38 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
39 'fs_page_break', 'fs_more_info', 'fs_pos_view'
40 ]
Rushabh Mehtad21f55b2014-04-29 16:24:37 +053041 for f in flds:
42 doc.set(f, 1)
Rushabh Mehtaf191f852014-04-02 18:09:34 +053043 doc.save()
Pratik Vyas28da7522014-02-19 20:53:45 +053044
45def set_single_defaults():
Nabin Haite7885e32014-04-04 13:26:50 +053046 for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""):
Anand Doshieb7fea62014-03-19 17:10:01 +053047 default_values = frappe.db.sql("""select fieldname, `default` from `tabDocField`
Rushabh Mehtaf14b8092014-04-03 14:30:42 +053048 where parent=%s""", dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053049 if default_values:
50 try:
Rushabh Mehtab385ecf2014-03-28 16:44:37 +053051 b = frappe.get_doc(dt, dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053052 for fieldname, value in default_values:
Anand Doshif78d1ae2014-03-28 13:55:00 +053053 b.set(fieldname, value)
Anand Doshieb7fea62014-03-19 17:10:01 +053054 b.save()
55 except frappe.MandatoryError:
56 pass
57
Anand Doshie9baaa62014-02-26 12:35:33 +053058 frappe.db.set_default("date_format", "dd-mm-yyyy")
Rushabh Mehtaa33d4682015-06-01 17:15:42 +053059
60def add_web_forms():
61 """Import web forms for Issues and Addresses"""
62 from frappe.modules.import_file import import_file_by_path
63
64 import_file_by_path(frappe.get_app_path("erpnext", "setup/fixtures/web_form/issues.json"),
65 data_import=True)
66 import_file_by_path(frappe.get_app_path("erpnext", "setup/fixtures/web_form/addresses.json"),
67 data_import=True)