blob: ce7af6dd4140167c2a762ddc145851f19bcfc2b5 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes 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 Mehta558a9aa2014-04-04 12:00:36 +053014 frappe.db.set_default('desktop:home_page', 'setup-wizard')
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053015 feature_setup()
Rushabh Mehta1f847992013-12-12 19:12:19 +053016 from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053017 add_all_roles_to("Administrator")
Anand Doshie9baaa62014-02-26 12:35:33 +053018 frappe.db.commit()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053019
Rushabh Mehta1f847992013-12-12 19:12:19 +053020def feature_setup():
21 """save global defaults and features setup"""
Rushabh Mehtaf191f852014-04-02 18:09:34 +053022 doc = frappe.get_doc("Features Setup", "Features Setup")
Anand Doshi6dfd4302015-02-10 14:41:27 +053023 doc.flags.ignore_permissions = True
Rushabh Mehta1f847992013-12-12 19:12:19 +053024
25 # store value as 1 for all these fields
26 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
27 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
28 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
29 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
30 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
31 'fs_page_break', 'fs_more_info', 'fs_pos_view'
32 ]
Rushabh Mehtad21f55b2014-04-29 16:24:37 +053033 for f in flds:
34 doc.set(f, 1)
Rushabh Mehtaf191f852014-04-02 18:09:34 +053035 doc.save()
Pratik Vyas28da7522014-02-19 20:53:45 +053036
37def set_single_defaults():
Nabin Haite7885e32014-04-04 13:26:50 +053038 for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""):
Anand Doshieb7fea62014-03-19 17:10:01 +053039 default_values = frappe.db.sql("""select fieldname, `default` from `tabDocField`
Rushabh Mehtaf14b8092014-04-03 14:30:42 +053040 where parent=%s""", dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053041 if default_values:
42 try:
Rushabh Mehtab385ecf2014-03-28 16:44:37 +053043 b = frappe.get_doc(dt, dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053044 for fieldname, value in default_values:
Anand Doshif78d1ae2014-03-28 13:55:00 +053045 b.set(fieldname, value)
Anand Doshieb7fea62014-03-19 17:10:01 +053046 b.save()
47 except frappe.MandatoryError:
48 pass
49
Anand Doshie9baaa62014-02-26 12:35:33 +053050 frappe.db.set_default("date_format", "dd-mm-yyyy")