Anand Doshi | 885e074 | 2015-03-03 14:55:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe 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 | d42167e | 2016-05-11 16:47:14 +0530 | [diff] [blame] | 7 | from frappe import _ |
Rushabh Mehta | 6f9915c | 2013-01-16 17:48:17 +0530 | [diff] [blame] | 8 | |
Anand Doshi | 56198f4 | 2014-06-26 12:47:45 +0530 | [diff] [blame] | 9 | 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] | 10 | <a style="color: #888" href="http://erpnext.org">ERPNext</a></div>""" |
| 11 | |
Rushabh Mehta | 1f84799 | 2013-12-12 19:12:19 +0530 | [diff] [blame] | 12 | def after_install(): |
Rushabh Mehta | 40b2b03 | 2014-04-21 13:43:11 +0530 | [diff] [blame] | 13 | frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert() |
Rushabh Mehta | 33003c6 | 2014-04-30 11:16:02 +0530 | [diff] [blame] | 14 | set_single_defaults() |
Rushabh Mehta | d42167e | 2016-05-11 16:47:14 +0530 | [diff] [blame] | 15 | create_compact_item_print_custom_field() |
Neil Trini Lasrado | 3c0d5cb | 2016-02-24 15:58:25 +0530 | [diff] [blame] | 16 | from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 17 | add_all_roles_to("Administrator") |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 18 | frappe.db.commit() |
Rushabh Mehta | db7139a | 2013-01-17 18:22:22 +0530 | [diff] [blame] | 19 | |
Rushabh Mehta | d55bdcf | 2015-12-31 11:12:48 +0530 | [diff] [blame] | 20 | def 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 | |
Pratik Vyas | 28da752 | 2014-02-19 20:53:45 +0530 | [diff] [blame] | 28 | def set_single_defaults(): |
Rushabh Mehta | b62ed7a | 2016-10-13 11:00:00 +0530 | [diff] [blame] | 29 | for dt in ('Accounts Settings', 'Print Settings', 'HR Settings', 'Buying Settings', |
Rushabh Mehta | fe816c3 | 2016-11-08 18:18:40 +0530 | [diff] [blame] | 30 | 'Selling Settings', 'Stock Settings', 'Daily Work Summary Settings'): |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 31 | default_values = frappe.db.sql("""select fieldname, `default` from `tabDocField` |
Rushabh Mehta | f14b809 | 2014-04-03 14:30:42 +0530 | [diff] [blame] | 32 | where parent=%s""", dt) |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 33 | if default_values: |
| 34 | try: |
Rushabh Mehta | b385ecf | 2014-03-28 16:44:37 +0530 | [diff] [blame] | 35 | b = frappe.get_doc(dt, dt) |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 36 | for fieldname, value in default_values: |
Anand Doshi | f78d1ae | 2014-03-28 13:55:00 +0530 | [diff] [blame] | 37 | b.set(fieldname, value) |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 38 | b.save() |
| 39 | except frappe.MandatoryError: |
| 40 | pass |
Rushabh Mehta | b62ed7a | 2016-10-13 11:00:00 +0530 | [diff] [blame] | 41 | except frappe.ValidationError: |
| 42 | pass |
Anand Doshi | eb7fea6 | 2014-03-19 17:10:01 +0530 | [diff] [blame] | 43 | |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 44 | frappe.db.set_default("date_format", "dd-mm-yyyy") |
Rushabh Mehta | d42167e | 2016-05-11 16:47:14 +0530 | [diff] [blame] | 45 | |
| 46 | def create_compact_item_print_custom_field(): |
| 47 | from frappe.custom.doctype.custom_field.custom_field import create_custom_field |
| 48 | create_custom_field('Print Settings', { |
| 49 | 'label': _('Compact Item Print'), |
| 50 | 'fieldname': 'compact_item_print', |
| 51 | 'fieldtype': 'Check', |
| 52 | 'default': 1, |
| 53 | 'insert_after': 'with_letterhead' |
| 54 | }) |