From 1aa3a115469f8ae2eba83fb1f6d64164f4e90c9f Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 3 May 2018 18:59:26 +0530 Subject: [PATCH] On auto-creation of new Fiscal Year, send Email notification to the account users (#13789) --- .../doctype/fiscal_year/fiscal_year.json | 53 ++++++++++++++++--- .../doctype/fiscal_year/fiscal_year.py | 1 + erpnext/accounts/email_alert/__init__.py | 0 .../__init__.py | 0 .../notification_for_new_fiscal_year.json | 28 ++++++++++ .../notification_for_new_fiscal_year.md | 3 ++ .../notification_for_new_fiscal_year.py | 5 ++ 7 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 erpnext/accounts/email_alert/__init__.py create mode 100644 erpnext/accounts/email_alert/notification_for_new_fiscal_year/__init__.py create mode 100644 erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.json create mode 100644 erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.md create mode 100644 erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json index f12de7915a..4ca9f6b96f 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_guest_to_view": 0, "allow_import": 1, "allow_rename": 0, "autoname": "field:year", @@ -13,6 +14,7 @@ "editable_grid": 0, "fields": [ { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -41,9 +43,11 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -70,9 +74,11 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -100,9 +106,11 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -128,9 +136,11 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -158,21 +168,54 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "0", + "fieldname": "auto_created", + "fieldtype": "Check", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Auto Created", + "length": 0, + "no_copy": 1, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, "unique": 0 } ], + "has_web_view": 0, "hide_heading": 0, "hide_toolbar": 0, "icon": "fa fa-calendar", "idx": 1, "image_view": 0, "in_create": 0, - "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-02-17 16:22:08.431278", + "modified": "2018-04-25 14:21:41.273354", "modified_by": "Administrator", "module": "Accounts", "name": "Fiscal Year", @@ -180,7 +223,6 @@ "permissions": [ { "amend": 0, - "apply_user_permissions": 0, "cancel": 0, "create": 1, "delete": 1, @@ -200,7 +242,6 @@ }, { "amend": 0, - "apply_user_permissions": 0, "cancel": 0, "create": 0, "delete": 0, @@ -220,7 +261,6 @@ }, { "amend": 0, - "apply_user_permissions": 0, "cancel": 0, "create": 0, "delete": 0, @@ -240,7 +280,6 @@ }, { "amend": 0, - "apply_user_permissions": 0, "cancel": 0, "create": 0, "delete": 0, @@ -260,7 +299,6 @@ }, { "amend": 0, - "apply_user_permissions": 0, "cancel": 0, "create": 0, "delete": 0, @@ -280,7 +318,6 @@ }, { "amend": 0, - "apply_user_permissions": 0, "cancel": 0, "create": 0, "delete": 0, diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py index 517a2a332e..92da787286 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py @@ -104,6 +104,7 @@ def auto_create_fiscal_year(): start_year = cstr(new_fy.year_start_date.year) end_year = cstr(new_fy.year_end_date.year) new_fy.year = start_year if start_year==end_year else (start_year + "-" + end_year) + new_fy.auto_created = 1 new_fy.insert(ignore_permissions=True) except frappe.NameError: diff --git a/erpnext/accounts/email_alert/__init__.py b/erpnext/accounts/email_alert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/email_alert/notification_for_new_fiscal_year/__init__.py b/erpnext/accounts/email_alert/notification_for_new_fiscal_year/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.json b/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.json new file mode 100644 index 0000000000..2e524d6e0f --- /dev/null +++ b/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.json @@ -0,0 +1,28 @@ +{ + "attach_print": 0, + "condition": "doc.auto_created", + "creation": "2018-04-25 14:19:05.440361", + "days_in_advance": 0, + "docstatus": 0, + "doctype": "Email Alert", + "document_type": "Fiscal Year", + "enabled": 1, + "event": "New", + "idx": 0, + "is_standard": 1, + "message": "

{{_(\"Fiscal Year\")}}

\n\n

{{ _(\"New fiscal year created :- \") }} {{ doc.name }}

", + "modified": "2018-04-25 14:30:38.588534", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Notification for new fiscal year", + "owner": "Administrator", + "recipients": [ + { + "email_by_role": "Accounts User" + }, + { + "email_by_role": "Accounts Manager" + } + ], + "subject": "Notification for new fiscal year {{ doc.name }}" +} \ No newline at end of file diff --git a/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.md b/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.md new file mode 100644 index 0000000000..c674ab6d0e --- /dev/null +++ b/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.md @@ -0,0 +1,3 @@ +

{{_("Fiscal Year")}}

+ +

{{ _("New fiscal year created :- ") }} {{ doc.name }}

\ No newline at end of file diff --git a/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py b/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py new file mode 100644 index 0000000000..1bc4d1874c --- /dev/null +++ b/erpnext/accounts/email_alert/notification_for_new_fiscal_year/notification_for_new_fiscal_year.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +def get_context(context): + # do your magic here + pass