blob: 1402168855749077287244a9327d405c5bea2b88 [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")
Anand Doshie9baaa62014-02-26 12:35:33 +053017 frappe.db.commit()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053018
Rushabh Mehtad55bdcf2015-12-31 11:12:48 +053019def check_setup_wizard_not_completed():
20 if frappe.db.get_default('desktop:home_page') == 'desktop':
21 print
22 print "ERPNext can only be installed on a fresh site where the setup wizard is not completed"
23 print "You can reinstall this site (after saving your data) using: bench --site [sitename] reinstall"
24 print
25 return False
26
Rushabh Mehta1f847992013-12-12 19:12:19 +053027def feature_setup():
28 """save global defaults and features setup"""
Rushabh Mehtaf191f852014-04-02 18:09:34 +053029 doc = frappe.get_doc("Features Setup", "Features Setup")
Anand Doshi6dfd4302015-02-10 14:41:27 +053030 doc.flags.ignore_permissions = True
Rushabh Mehta1f847992013-12-12 19:12:19 +053031
32 # store value as 1 for all these fields
33 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
34 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
35 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
36 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
37 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
shreyas6f8dfa42016-03-07 18:22:40 +053038 'fs_page_break', 'fs_more_info', 'fs_pos_view', 'compact_item_print'
Rushabh Mehta1f847992013-12-12 19:12:19 +053039 ]
Rushabh Mehtad21f55b2014-04-29 16:24:37 +053040 for f in flds:
41 doc.set(f, 1)
Rushabh Mehtaf191f852014-04-02 18:09:34 +053042 doc.save()
Pratik Vyas28da7522014-02-19 20:53:45 +053043
44def set_single_defaults():
Nabin Haite7885e32014-04-04 13:26:50 +053045 for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""):
Anand Doshieb7fea62014-03-19 17:10:01 +053046 default_values = frappe.db.sql("""select fieldname, `default` from `tabDocField`
Rushabh Mehtaf14b8092014-04-03 14:30:42 +053047 where parent=%s""", dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053048 if default_values:
49 try:
Rushabh Mehtab385ecf2014-03-28 16:44:37 +053050 b = frappe.get_doc(dt, dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053051 for fieldname, value in default_values:
Anand Doshif78d1ae2014-03-28 13:55:00 +053052 b.set(fieldname, value)
Anand Doshieb7fea62014-03-19 17:10:01 +053053 b.save()
54 except frappe.MandatoryError:
55 pass
56
Anand Doshie9baaa62014-02-26 12:35:33 +053057 frappe.db.set_default("date_format", "dd-mm-yyyy")