From 1f6cc2b6ec4adb60fb660714560f2e8145850972 Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Mon, 3 Feb 2020 17:52:42 +0530 Subject: [PATCH] feat: appointment Letter (#20104) * feat: appointment Letter * fix: requested changes Co-authored-by: Nabin Hait --- erpnext/config/hr.py | 4 + .../hr/doctype/appointment_letter/__init__.py | 0 .../appointment_letter/appointment_letter.js | 30 +++++ .../appointment_letter.json | 124 ++++++++++++++++++ .../appointment_letter/appointment_letter.py | 25 ++++ .../test_appointment_letter.py | 10 ++ .../appointment_letter_content/__init__.py | 0 .../appointment_letter_content.json | 39 ++++++ .../appointment_letter_content.py | 10 ++ .../appointment_letter_template/__init__.py | 0 .../appointment_letter_template.js | 8 ++ .../appointment_letter_template.json | 69 ++++++++++ .../appointment_letter_template.py | 10 ++ .../test_appointment_letter_template.py | 10 ++ .../standard_appointment_letter/__init__.py | 0 .../standard_appointment_letter.html | 38 ++++++ .../standard_appointment_letter.json | 23 ++++ 17 files changed, 400 insertions(+) create mode 100644 erpnext/hr/doctype/appointment_letter/__init__.py create mode 100644 erpnext/hr/doctype/appointment_letter/appointment_letter.js create mode 100644 erpnext/hr/doctype/appointment_letter/appointment_letter.json create mode 100644 erpnext/hr/doctype/appointment_letter/appointment_letter.py create mode 100644 erpnext/hr/doctype/appointment_letter/test_appointment_letter.py create mode 100644 erpnext/hr/doctype/appointment_letter_content/__init__.py create mode 100644 erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.json create mode 100644 erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.py create mode 100644 erpnext/hr/doctype/appointment_letter_template/__init__.py create mode 100644 erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.js create mode 100644 erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.json create mode 100644 erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.py create mode 100644 erpnext/hr/doctype/appointment_letter_template/test_appointment_letter_template.py create mode 100644 erpnext/hr/print_format/standard_appointment_letter/__init__.py create mode 100644 erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.html create mode 100644 erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.json diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py index 4e5e9037b3..7b3b4660f5 100644 --- a/erpnext/config/hr.py +++ b/erpnext/config/hr.py @@ -289,6 +289,10 @@ def get_data(): "name": "Job Offer", "onboard": 1, }, + { + "type": "doctype", + "name": "Appointment Letter", + }, { "type": "doctype", "name": "Staffing Plan", diff --git a/erpnext/hr/doctype/appointment_letter/__init__.py b/erpnext/hr/doctype/appointment_letter/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/doctype/appointment_letter/appointment_letter.js b/erpnext/hr/doctype/appointment_letter/appointment_letter.js new file mode 100644 index 0000000000..a338dc6513 --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter/appointment_letter.js @@ -0,0 +1,30 @@ +// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Appointment Letter', { + appointment_letter_template: function(frm){ + if (frm.doc.appointment_letter_template){ + frappe.call({ + method: 'erpnext.hr.doctype.appointment_letter.appointment_letter.get_appointment_letter_details', + args : { + template : frm.doc.appointment_letter_template + }, + callback: function(r){ + if(r.message){ + let message_body = r.message; + frm.set_value("introduction", message_body[0].introduction); + frm.set_value("closing_notes", message_body[0].closing_notes); + frm.doc.terms = [] + for (var i in message_body[1].description){ + frm.add_child("terms"); + frm.fields_dict.terms.get_value()[i].title = message_body[1].description[i].title; + frm.fields_dict.terms.get_value()[i].description = message_body[1].description[i].description; + } + frm.refresh(); + } + } + + }); + } + }, +}); diff --git a/erpnext/hr/doctype/appointment_letter/appointment_letter.json b/erpnext/hr/doctype/appointment_letter/appointment_letter.json new file mode 100644 index 0000000000..c81b7004f6 --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter/appointment_letter.json @@ -0,0 +1,124 @@ +{ + "actions": [], + "autoname": "HR-APP-LETTER-.#####", + "creation": "2019-12-26 12:35:49.574828", + "default_print_format": "Standard Appointment Letter", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "job_applicant", + "applicant_name", + "column_break_3", + "company", + "appointment_date", + "appointment_letter_template", + "body_section", + "introduction", + "terms", + "closing_notes" + ], + "fields": [ + { + "fetch_from": "job_applicant.applicant_name", + "fieldname": "applicant_name", + "fieldtype": "Data", + "in_global_search": 1, + "in_list_view": 1, + "label": "Applicant Name", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "appointment_date", + "fieldtype": "Date", + "label": "Appointment Date", + "reqd": 1 + }, + { + "fieldname": "appointment_letter_template", + "fieldtype": "Link", + "label": "Appointment Letter Template", + "options": "Appointment Letter Template", + "reqd": 1 + }, + { + "fetch_from": "appointment_letter_template.introduction", + "fieldname": "introduction", + "fieldtype": "Long Text", + "label": "Introduction", + "reqd": 1 + }, + { + "fieldname": "body_section", + "fieldtype": "Section Break", + "label": "Body" + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "fieldname": "job_applicant", + "fieldtype": "Link", + "label": "Job Applicant", + "options": "Job Applicant", + "reqd": 1 + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "reqd": 1 + }, + { + "fieldname": "closing_notes", + "fieldtype": "Text", + "label": "Closing Notes" + }, + { + "fieldname": "terms", + "fieldtype": "Table", + "label": "Terms", + "options": "Appointment Letter content", + "reqd": 1 + } + ], + "links": [], + "modified": "2020-01-21 17:30:36.334395", + "modified_by": "Administrator", + "module": "HR", + "name": "Appointment Letter", + "name_case": "Title Case", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/hr/doctype/appointment_letter/appointment_letter.py b/erpnext/hr/doctype/appointment_letter/appointment_letter.py new file mode 100644 index 0000000000..85b82c5014 --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter/appointment_letter.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class AppointmentLetter(Document): + pass + +@frappe.whitelist() +def get_appointment_letter_details(template): + body = [] + intro= frappe.get_list("Appointment Letter Template", + fields = ['introduction', 'closing_notes'], + filters={'name': template + })[0] + content = frappe.get_list("Appointment Letter content", + fields = ['title', 'description'], + filters={'parent': template + }) + body.append(intro) + body.append({'description': content}) + return body diff --git a/erpnext/hr/doctype/appointment_letter/test_appointment_letter.py b/erpnext/hr/doctype/appointment_letter/test_appointment_letter.py new file mode 100644 index 0000000000..b9ce9819c5 --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter/test_appointment_letter.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestAppointmentLetter(unittest.TestCase): + pass diff --git a/erpnext/hr/doctype/appointment_letter_content/__init__.py b/erpnext/hr/doctype/appointment_letter_content/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.json b/erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.json new file mode 100644 index 0000000000..17a2b91cff --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.json @@ -0,0 +1,39 @@ +{ + "actions": [], + "creation": "2019-12-26 12:22:16.575767", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "title", + "description" + ], + "fields": [ + { + "fieldname": "title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Title", + "reqd": 1 + }, + { + "fieldname": "description", + "fieldtype": "Long Text", + "in_list_view": 1, + "label": "Description", + "reqd": 1 + } + ], + "istable": 1, + "links": [], + "modified": "2019-12-26 12:24:09.824084", + "modified_by": "Administrator", + "module": "HR", + "name": "Appointment Letter content", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.py b/erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.py new file mode 100644 index 0000000000..a1a49e536b --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter_content/appointment_letter_content.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class AppointmentLettercontent(Document): + pass diff --git a/erpnext/hr/doctype/appointment_letter_template/__init__.py b/erpnext/hr/doctype/appointment_letter_template/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.js b/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.js new file mode 100644 index 0000000000..8270f7aca2 --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.js @@ -0,0 +1,8 @@ +// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Appointment Letter Template', { + // refresh: function(frm) { + + // } +}); diff --git a/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.json b/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.json new file mode 100644 index 0000000000..c136fb22fa --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.json @@ -0,0 +1,69 @@ +{ + "actions": [], + "autoname": "HR-APP-LETTER-TEMP-.#####", + "creation": "2019-12-26 12:20:14.219578", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "introduction", + "terms", + "closing_notes" + ], + "fields": [ + { + "fieldname": "introduction", + "fieldtype": "Long Text", + "in_list_view": 1, + "label": "Introduction", + "reqd": 1 + }, + { + "fieldname": "closing_notes", + "fieldtype": "Text", + "label": "Closing Notes" + }, + { + "fieldname": "terms", + "fieldtype": "Table", + "label": "Terms", + "options": "Appointment Letter content", + "reqd": 1 + } + ], + "links": [], + "modified": "2020-01-21 17:00:46.779420", + "modified_by": "Administrator", + "module": "HR", + "name": "Appointment Letter Template", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "HR Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.py b/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.py new file mode 100644 index 0000000000..c23881f800 --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter_template/appointment_letter_template.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class AppointmentLetterTemplate(Document): + pass diff --git a/erpnext/hr/doctype/appointment_letter_template/test_appointment_letter_template.py b/erpnext/hr/doctype/appointment_letter_template/test_appointment_letter_template.py new file mode 100644 index 0000000000..3d061ac8e9 --- /dev/null +++ b/erpnext/hr/doctype/appointment_letter_template/test_appointment_letter_template.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestAppointmentLetterTemplate(unittest.TestCase): + pass diff --git a/erpnext/hr/print_format/standard_appointment_letter/__init__.py b/erpnext/hr/print_format/standard_appointment_letter/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.html b/erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.html new file mode 100644 index 0000000000..d60582e1a1 --- /dev/null +++ b/erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.html @@ -0,0 +1,38 @@ +{%- from "templates/print_formats/standard_macros.html" import add_header -%} + +

Appointment Letter

+
+
+ {{ doc.applicant_name }}, +
+
+ Date: {{ doc.appointment_date }} +
+
+
+ {{ doc.introduction }} +
+
+ +
+
+Your sincerely,
+For {{ doc.company }} +
+ +
+ {{ doc.closing_notes }} +
+ +
+ ________________
+ {{ doc.applicant_name }} +
\ No newline at end of file diff --git a/erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.json b/erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.json new file mode 100644 index 0000000000..1813e711f5 --- /dev/null +++ b/erpnext/hr/print_format/standard_appointment_letter/standard_appointment_letter.json @@ -0,0 +1,23 @@ +{ + "align_labels_right": 0, + "creation": "2019-12-26 15:22:44.200332", + "custom_format": 0, + "default_print_language": "en", + "disabled": 0, + "doc_type": "Appointment Letter", + "docstatus": 0, + "doctype": "Print Format", + "font": "Default", + "idx": 0, + "line_breaks": 0, + "modified": "2020-01-21 17:24:16.705082", + "modified_by": "Administrator", + "module": "HR", + "name": "Standard Appointment Letter", + "owner": "Administrator", + "print_format_builder": 0, + "print_format_type": "Jinja", + "raw_printing": 0, + "show_section_headings": 0, + "standard": "Yes" +} \ No newline at end of file