Skip to content

Commit

Permalink
Merge pull request #1241 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
ruchamahabal authored Dec 30, 2023
2 parents 5c83e08 + 787ab36 commit 5085552
Show file tree
Hide file tree
Showing 17 changed files with 313 additions and 92 deletions.
7 changes: 7 additions & 0 deletions hrms/hr/doctype/hr_settings/hr_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ frappe.ui.form.on('HR Settings', {
},
};
});
frm.set_query("hiring_sender", () => {
return {
filters: {
enable_outgoing: 1,
},
};
});
}
});

Expand Down
20 changes: 18 additions & 2 deletions hrms/hr/doctype/hr_settings/hr_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
"send_interview_reminder",
"interview_reminder_template",
"remind_before",
"column_break_4",
"send_interview_feedback_reminder",
"feedback_reminder_notification_template",
"column_break_4",
"hiring_sender",
"hiring_sender_email",
"employee_exit_section",
"exit_questionnaire_web_form",
"column_break_34",
Expand Down Expand Up @@ -270,6 +272,20 @@
"fieldname": "column_break_hyec",
"fieldtype": "Column Break"
},
{
"fieldname": "hiring_sender",
"fieldtype": "Link",
"label": "Sender",
"options": "Email Account"
},
{
"depends_on": "eval:doc.hiring_sender",
"fetch_from": "hiring_sender.email_id",
"fieldname": "hiring_sender_email",
"fieldtype": "Data",
"label": "Sender Email",
"read_only": 1
},
{
"default": "1",
"fieldname": "allow_multiple_shift_assignments",
Expand All @@ -286,7 +302,7 @@
"idx": 1,
"issingle": 1,
"links": [],
"modified": "2023-12-07 14:55:37.309553",
"modified": "2023-12-28 23:07:36.317223",
"modified_by": "Administrator",
"module": "HR",
"name": "HR Settings",
Expand Down
66 changes: 63 additions & 3 deletions hrms/hr/doctype/interview/interview.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def validate(self):
def on_submit(self):
if self.status not in ["Cleared", "Rejected"]:
frappe.throw(
_("Only Interviews with Cleared or Rejected status can be submitted."), title=_("Not Allowed")
_("Only Interviews with Cleared or Rejected status can be submitted."),
title=_("Not Allowed"),
)
self.show_job_applicant_update_dialog()

def validate_duplicate_interview(self):
duplicate_interview = frappe.db.exists(
Expand Down Expand Up @@ -102,6 +104,29 @@ def set_average_rating(self):
total_rating / len(self.interview_details) if len(self.interview_details) else 0
)

def show_job_applicant_update_dialog(self):
job_applicant_status = self.get_job_applicant_status()
if not job_applicant_status:
return

job_application_name = frappe.db.get_value("Job Applicant", self.job_applicant, "applicant_name")

frappe.msgprint(
_("Do you want to update the Job Applicant {0} as {1} based on this interview result?").format(
frappe.bold(job_application_name), frappe.bold(job_applicant_status)
),
title=_("Update Job Applicant"),
primary_action={
"label": _("Mark as {0}").format(job_applicant_status),
"server_action": "hrms.hr.doctype.interview.interview.update_job_applicant_status",
"args": {"job_applicant": self.job_applicant, "status": job_applicant_status},
},
)

def get_job_applicant_status(self) -> str | None:
status_map = {"Cleared": "Accepted", "Rejected": "Rejected"}
return status_map.get(self.status, None)

@frappe.whitelist()
def reschedule_interview(self, scheduled_on, from_time, to_time):
original_date = self.scheduled_on
Expand Down Expand Up @@ -148,6 +173,35 @@ def get_recipients(name, for_feedback=0):
return recipients


@frappe.whitelist()
def update_job_applicant_status(args):
import json

try:
if isinstance(args, str):
args = json.loads(args)

if not args.get("job_applicant"):
frappe.throw(_("Please specify the job applicant to be updated."))

job_applicant = frappe.get_doc("Job Applicant", args["job_applicant"])
job_applicant.status = args["status"]
job_applicant.save()

frappe.msgprint(
_("Updated the Job Applicant status to {0}").format(job_applicant.status),
alert=True,
indicator="green",
)
except Exception:
job_applicant.log_error("Failed to update Job Applicant status")
frappe.msgprint(
_("Failed to update the Job Applicant status"),
alert=True,
indicator="red",
)


@frappe.whitelist()
def get_interviewers(interview_round):
return frappe.get_all(
Expand All @@ -159,7 +213,7 @@ def send_interview_reminder():
reminder_settings = frappe.db.get_value(
"HR Settings",
"HR Settings",
["send_interview_reminder", "interview_reminder_template"],
["send_interview_reminder", "interview_reminder_template", "hiring_sender_email"],
as_dict=True,
)

Expand Down Expand Up @@ -193,6 +247,7 @@ def send_interview_reminder():
recipients = get_recipients(doc.name)

frappe.sendmail(
sender=reminder_settings.hiring_sender_email,
recipients=recipients,
subject=interview_template.subject,
message=message,
Expand All @@ -207,7 +262,11 @@ def send_daily_feedback_reminder():
reminder_settings = frappe.db.get_value(
"HR Settings",
"HR Settings",
["send_interview_feedback_reminder", "feedback_reminder_notification_template"],
[
"send_interview_feedback_reminder",
"feedback_reminder_notification_template",
"hiring_sender_email",
],
as_dict=True,
)

Expand Down Expand Up @@ -238,6 +297,7 @@ def send_daily_feedback_reminder():

if len(recipients):
frappe.sendmail(
sender=reminder_settings.hiring_sender_email,
recipients=recipients,
subject=interview_feedback_template.subject,
message=message,
Expand Down
14 changes: 13 additions & 1 deletion hrms/hr/doctype/interview/test_interview.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

from erpnext.setup.doctype.designation.test_designation import create_designation

from hrms.hr.doctype.interview.interview import DuplicateInterviewRoundError
from hrms.hr.doctype.interview.interview import (
DuplicateInterviewRoundError,
update_job_applicant_status,
)
from hrms.hr.doctype.job_applicant.job_applicant import get_interview_details
from hrms.tests.test_utils import create_job_applicant

Expand Down Expand Up @@ -109,6 +112,15 @@ def test_get_interview_details_for_applicant_dashboard(self):
},
)

def test_job_applicant_status_update_on_interview_submit(self):
job_applicant = create_job_applicant()
interview = create_interview_and_dependencies(job_applicant.name, status="Cleared")

update_job_applicant_status({"job_applicant": job_applicant.name, "status": "Accepted"})
job_applicant.reload()

self.assertEqual(job_applicant.status, "Accepted")

def tearDown(self):
frappe.db.rollback()

Expand Down
12 changes: 12 additions & 0 deletions hrms/hr/doctype/job_offer/job_offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ frappe.ui.form.on("Job Offer", {
}
});
},
job_offer_term_template: function (frm) {
if (!frm.doc.job_offer_term_template) return;

frappe.db.get_doc("Job Offer Term Template", frm.doc.job_offer_term_template).then((doc) => {
frm.clear_table("offer_terms");
doc.offer_terms.forEach((term) => {
frm.add_child("offer_terms", term);
})
refresh_field("offer_terms");
})

},

refresh: function (frm) {
if ((!frm.doc.__islocal) && (frm.doc.status == 'Accepted')
Expand Down
9 changes: 8 additions & 1 deletion hrms/hr/doctype/job_offer/job_offer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"designation",
"company",
"section_break_4",
"job_offer_term_template",
"offer_terms",
"section_break_14",
"select_terms",
Expand Down Expand Up @@ -156,11 +157,17 @@
"options": "Job Offer",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "job_offer_term_template",
"fieldtype": "Link",
"label": "Job Offer Term Template",
"options": "Job Offer Term Template"
}
],
"is_submittable": 1,
"links": [],
"modified": "2020-06-25 00:56:24.756395",
"modified": "2023-11-21 13:41:22.022838",
"modified_by": "Administrator",
"module": "HR",
"name": "Job Offer",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt

// frappe.ui.form.on("Job Offer Term Template", {
// refresh(frm) {

// },
// });
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:title",
"creation": "2023-11-21 13:39:20.882706",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"title",
"offer_terms"
],
"fields": [
{
"fieldname": "title",
"fieldtype": "Data",
"label": "Title",
"unique": 1
},
{
"fieldname": "offer_terms",
"fieldtype": "Table",
"label": "Offer Terms",
"options": "Job Offer Term"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-29 13:08:24.269275",
"modified_by": "Administrator",
"module": "HR",
"name": "Job Offer Term Template",
"naming_rule": "By fieldname",
"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",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class JobOfferTermTemplate(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestJobOfferTermTemplate(FrappeTestCase):
pass
Loading

0 comments on commit 5085552

Please sign in to comment.