blob: dce101ea916242b94b89ed0171d0568d3b7877e0 [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
Rushabh Mehta370a0242014-04-18 16:00:41 +05308from frappe import _
9
Anand Doshi56198f42014-06-26 12:47:45 +053010default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
Anand Doshi7f41ff22014-06-26 12:02:55 +053011 <a style="color: #888" href="http://erpnext.org">ERPNext</a></div>"""
12
Rushabh Mehta1f847992013-12-12 19:12:19 +053013def after_install():
Rushabh Mehta40b2b032014-04-21 13:43:11 +053014 frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
Rushabh Mehta33003c62014-04-30 11:16:02 +053015 set_single_defaults()
Nabin Hait813a93d2014-03-06 18:21:56 +053016 from erpnext.accounts.doctype.chart_of_accounts.import_charts import import_charts
17 import_charts()
Rushabh Mehta558a9aa2014-04-04 12:00:36 +053018 frappe.db.set_default('desktop:home_page', 'setup-wizard')
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053019 feature_setup()
Rushabh Mehta1f847992013-12-12 19:12:19 +053020 from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053021 add_all_roles_to("Administrator")
Anand Doshie9baaa62014-02-26 12:35:33 +053022 frappe.db.commit()
Rushabh Mehtadb7139a2013-01-17 18:22:22 +053023
Rushabh Mehta1f847992013-12-12 19:12:19 +053024def feature_setup():
25 """save global defaults and features setup"""
Rushabh Mehtaf191f852014-04-02 18:09:34 +053026 doc = frappe.get_doc("Features Setup", "Features Setup")
27 doc.ignore_permissions = True
Rushabh Mehta1f847992013-12-12 19:12:19 +053028
29 # store value as 1 for all these fields
30 flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
31 'fs_item_advanced', 'fs_packing_details', 'fs_item_group_in_details',
32 'fs_exports', 'fs_imports', 'fs_discounts', 'fs_purchase_discounts',
33 'fs_after_sales_installations', 'fs_projects', 'fs_sales_extras',
34 'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
35 'fs_page_break', 'fs_more_info', 'fs_pos_view'
36 ]
Rushabh Mehtad21f55b2014-04-29 16:24:37 +053037 for f in flds:
38 doc.set(f, 1)
Rushabh Mehtaf191f852014-04-02 18:09:34 +053039 doc.save()
Pratik Vyas28da7522014-02-19 20:53:45 +053040
41def set_single_defaults():
Nabin Haite7885e32014-04-04 13:26:50 +053042 for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""):
Anand Doshieb7fea62014-03-19 17:10:01 +053043 default_values = frappe.db.sql("""select fieldname, `default` from `tabDocField`
Rushabh Mehtaf14b8092014-04-03 14:30:42 +053044 where parent=%s""", dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053045 if default_values:
46 try:
Rushabh Mehtab385ecf2014-03-28 16:44:37 +053047 b = frappe.get_doc(dt, dt)
Anand Doshieb7fea62014-03-19 17:10:01 +053048 for fieldname, value in default_values:
Anand Doshif78d1ae2014-03-28 13:55:00 +053049 b.set(fieldname, value)
Anand Doshieb7fea62014-03-19 17:10:01 +053050 b.save()
51 except frappe.MandatoryError:
52 pass
53
Anand Doshie9baaa62014-02-26 12:35:33 +053054 frappe.db.set_default("date_format", "dd-mm-yyyy")