Skip to content

Commit

Permalink
Merge pull request #453 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal authored Apr 18, 2023
2 parents 512fb9a + bd4888f commit 3ba4182
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 88 deletions.
14 changes: 3 additions & 11 deletions .github/helper/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
from urllib.parse import urlparse


docs_repos = [
"frappe_docs",
"erpnext_documentation",
"erpnext_com",
"frappe_io",
]


def uri_validator(x):
result = urlparse(x)
return all([result.scheme, result.netloc, result.path])
Expand All @@ -22,15 +14,15 @@ def docs_link_exists(body):
parsed_url = urlparse(word)
if parsed_url.netloc == "github.com":
parts = parsed_url.path.split('/')
if len(parts) == 5 and parts[1] == "frappe" and parts[2] in docs_repos:
if len(parts) == 5 and parts[1] == "frappe" and parts[2] == "hrms":
return True
elif parsed_url.netloc == "docs.erpnext.com":
elif parsed_url.netloc == "frappehr.com":
return True


if __name__ == "__main__":
pr = sys.argv[1]
response = requests.get("https://api.github.com/repos/frappe/erpnext/pulls/{}".format(pr))
response = requests.get("https://api.github.com/repos/frappe/hrms/pulls/{}".format(pr))

if response.ok:
payload = response.json()
Expand Down
2 changes: 1 addition & 1 deletion hrms/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "14.2.1"
__version__ = "14.2.2"
2 changes: 1 addition & 1 deletion hrms/hr/doctype/appraisal/appraisal.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def set_kras_and_rating_criteria(self):
self.append(
table_name,
{
"kra": entry.kra,
"kra": entry.key_result_area,
"per_weightage": entry.per_weightage,
},
)
Expand Down
2 changes: 1 addition & 1 deletion hrms/hr/doctype/appraisal_cycle/test_appraisal_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_create_appraisals(self):

for i in range(2):
# check if KRAs are set
self.assertEqual(appraisal.appraisal_kra[i].kra, self.template.goals[i].kra)
self.assertEqual(appraisal.appraisal_kra[i].kra, self.template.goals[i].key_result_area)
self.assertEqual(appraisal.appraisal_kra[i].per_weightage, self.template.goals[i].per_weightage)

# check if rating criteria is set
Expand Down
6 changes: 3 additions & 3 deletions hrms/hr/doctype/appraisal_template/test_appraisal_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def create_appraisal_template(title=None, kras=None, rating_criteria=None):
if not kras:
kras = [
{
"kra": "Quality",
"key_result_area": "Quality",
"per_weightage": 30,
},
{
"kra": "Development",
"key_result_area": "Development",
"per_weightage": 70,
},
]
Expand All @@ -71,7 +71,7 @@ def create_appraisal_template(title=None, kras=None, rating_criteria=None):
},
]

create_kras([entry["kra"] for entry in kras])
create_kras([entry["key_result_area"] for entry in kras])
create_criteria([entry["criteria"] for entry in rating_criteria])

appraisal_template = frappe.new_doc("Appraisal Template")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,10 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"kra",
"key_result_area",
"per_weightage"
],
"fields": [
{
"description": "Key Performance Area",
"fieldname": "kra",
"fieldtype": "Link",
"in_list_view": 1,
"label": "KRA",
"oldfieldname": "kra",
"oldfieldtype": "Small Text",
"options": "KRA",
"print_width": "200px",
"reqd": 1,
"width": "200px"
},
{
"fieldname": "per_weightage",
"fieldtype": "Percent",
Expand All @@ -33,12 +20,21 @@
"print_width": "100px",
"reqd": 1,
"width": "100px"
},
{
"description": "Key Result Area",
"fieldname": "key_result_area",
"fieldtype": "Link",
"in_list_view": 1,
"label": "KRA",
"options": "KRA",
"reqd": 1
}
],
"idx": 1,
"istable": 1,
"links": [],
"modified": "2022-08-29 17:57:02.907867",
"modified": "2023-04-17 17:01:46.294286",
"modified_by": "Administrator",
"module": "HR",
"name": "Appraisal Template Goal",
Expand Down
24 changes: 17 additions & 7 deletions hrms/hr/doctype/attendance/attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
add_days,
cint,
cstr,
formatdate,
format_date,
get_datetime,
get_link_to_form,
getdate,
Expand Down Expand Up @@ -53,9 +53,19 @@ def validate_attendance_date(self):
and not self.leave_application
and getdate(self.attendance_date) > getdate(nowdate())
):
frappe.throw(_("Attendance can not be marked for future dates"))
frappe.throw(
_("Attendance can not be marked for future dates: {0}").format(
frappe.bold(format_date(self.attendance_date)),
)
)
elif date_of_joining and getdate(self.attendance_date) < getdate(date_of_joining):
frappe.throw(_("Attendance date can not be less than employee's joining date"))
frappe.throw(
_("Attendance date {0} can not be less than employee {1}'s joining date: {2}").format(
frappe.bold(format_date(self.attendance_date)),
frappe.bold(self.employee),
frappe.bold(format_date(date_of_joining)),
)
)

def validate_duplicate_record(self):
duplicate = get_duplicate_attendance_record(
Expand All @@ -66,7 +76,7 @@ def validate_duplicate_record(self):
frappe.throw(
_("Attendance for employee {0} is already marked for the date {1}: {2}").format(
frappe.bold(self.employee),
frappe.bold(self.attendance_date),
frappe.bold(format_date(self.attendance_date)),
get_link_to_form("Attendance", duplicate[0].name),
),
title=_("Duplicate Attendance"),
Expand Down Expand Up @@ -112,19 +122,19 @@ def check_leave_record(self):
if d.half_day_date == getdate(self.attendance_date):
self.status = "Half Day"
frappe.msgprint(
_("Employee {0} on Half day on {1}").format(self.employee, formatdate(self.attendance_date))
_("Employee {0} on Half day on {1}").format(self.employee, format_date(self.attendance_date))
)
else:
self.status = "On Leave"
frappe.msgprint(
_("Employee {0} is on Leave on {1}").format(self.employee, formatdate(self.attendance_date))
_("Employee {0} is on Leave on {1}").format(self.employee, format_date(self.attendance_date))
)

if self.status in ("On Leave", "Half Day"):
if not leave_record:
frappe.msgprint(
_("No leave record found for employee {0} on {1}").format(
self.employee, formatdate(self.attendance_date)
self.employee, format_date(self.attendance_date)
),
alert=1,
)
Expand Down
1 change: 1 addition & 0 deletions hrms/overrides/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def make_salary_components(country):
try:
doc = frappe.get_doc(d)
doc.flags.ignore_permissions = True
doc.flags.ignore_mandatory = True
doc.insert(ignore_if_duplicate=True)
except frappe.NameError:
frappe.clear_messages()
Expand Down
6 changes: 3 additions & 3 deletions hrms/patches.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[pre_model_sync]
hrms.patches.v14_0.update_performance_module_changes

[post_model_sync]
hrms.patches.post_install.set_payroll_entry_status
hrms.patches.v1_0.rearrange_employee_fields
hrms.patches.v1_0.update_allocate_on_in_leave_type
hrms.patches.v14_0.create_custom_field_for_appraisal_template
hrms.patches.post_install.update_allocate_on_in_leave_type
hrms.patches.v14_0.create_custom_field_for_appraisal_template
hrms.patches.post_install.update_performance_module_changes #2023-04-17
7 changes: 0 additions & 7 deletions hrms/patches/post_install/drop_column_max_days_allowed.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def execute():
if not frappe.db.table_exists("Daily Work Summary Group"):
if frappe.db.table_exists("Daily Work Summary Settings"):
frappe.reload_doc("hr", "doctype", "daily_work_summary_group")
frappe.reload_doc("hr", "doctype", "daily_work_summary_group_user")

Expand Down Expand Up @@ -37,6 +37,7 @@ def execute():
)
new_group.flags.ignore_permissions = True
new_group.flags.ignore_validate = True
new_group.flags.ignore_mandatory = True
new_group.insert(ignore_if_duplicate=True)

frappe.delete_doc_if_exists("DocType", "Daily Work Summary Settings")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@


def execute():
if frappe.db.exists("DocType", {"module": "Payroll", "name": "Employee Incentive"}):
return

frappe.db.sql(
"""UPDATE `tabPrint Format`
SET module = 'Payroll'
WHERE name IN ('Salary Slip Based On Timesheet', 'Salary Slip Standard')"""
SET module = 'Payroll'
WHERE name IN ('Salary Slip Based On Timesheet', 'Salary Slip Standard')"""
)

frappe.db.sql("""UPDATE `tabNotification` SET module='Payroll' WHERE name='Retention Bonus';""")

doctypes_moved = [
"Employee Benefit Application Detail",
"Employee Tax Exemption Declaration Category",
Expand Down
5 changes: 5 additions & 0 deletions hrms/patches/post_install/rename_field_max_days_allowed.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ def execute():
frappe.db.sql_ddl("""ALTER table `tabLeave Type` modify max_days_allowed int(8) NOT NULL""")
frappe.reload_doc("hr", "doctype", "leave_type")
rename_field("Leave Type", "max_days_allowed", "max_continuous_days_allowed")

if frappe.db.has_column("Leave Type", "max_days_allowed"):
frappe.db.sql("alter table `tabLeave Type` drop column max_days_allowed")
# clear cache for doctype as it stores table columns in cache
frappe.clear_cache(doctype="Leave Type")
18 changes: 9 additions & 9 deletions hrms/patches/post_install/set_job_offer_applicant_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@


def execute():
frappe.reload_doc("hr", "doctype", "job_offer")
Offer = frappe.qb.DocType("Job Offer")
Applicant = frappe.qb.DocType("Job Applicant")

frappe.db.sql(
"""
UPDATE
`tabJob Offer` AS offer
SET
applicant_email = (SELECT email_id FROM `tabJob Applicant` WHERE name = offer.job_applicant)
"""
)
(
frappe.qb.update(Offer)
.inner_join(Applicant)
.on(Applicant.name == Offer.job_applicant)
.set(Offer.applicant_email, Applicant.email_id)
.where(Offer.applicant_email.isnull())
).run()
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


def execute():
frappe.clear_cache(doctype="Leave Type")

if frappe.db.has_column("Leave Type", "based_on_date_of_joining"):
LeaveType = frappe.qb.DocType("Leave Type")
frappe.qb.update(LeaveType).set(LeaveType.allocate_on_day, "Last Day").where(
Expand All @@ -13,3 +15,5 @@ def execute():
).run()

frappe.db.sql_ddl("alter table `tabLeave Type` drop column `based_on_date_of_joining`")
# clear cache for doctype as it stores table columns in cache
frappe.clear_cache(doctype="Leave Type")
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@

def execute():
create_kras()

for doctype in (
"Appraisal Template",
"Appraisal Cycle",
"Appraisal KRA",
"Appraisal Goal",
"Employee Feedback Rating",
"Appraisal",
):
frappe.reload_doc("hr", "doctype", doctype)

rename_fields()
update_kra_evaluation_method()


def create_kras():
# Appraisal Template Goal's KRA field was changed from Small Text to Link
# A new Link field `key_result_area` was added in the Appraisal Template Goal table
# Old field's (`kra` (Small Text)) data now needs to be copied to the new field
# This patch will create KRA's for all existing Appraisal Template Goal entries
# keeping 140 characters as the KRA title and the whole KRA as the description
frappe.reload_doc("hr", "doctype", "kra")
# and then set the new title (140 characters) in the `key_result_area` field
if not frappe.db.has_column("Appraisal Template Goal", "kra"):
return

template_goals = frappe.get_all("Appraisal Template Goal", fields=["name", "kra"], as_list=True)
template_goals = frappe.get_all(
"Appraisal Template Goal",
filters={"parenttype": "Appraisal Template"},
fields=["name", "kra"],
as_list=True,
)

if len(template_goals) > 10000:
frappe.db.auto_commit_on_many_writes = 1
Expand All @@ -48,7 +45,10 @@ def create_kras():
}
).db_insert()

frappe.db.set_value("Appraisal Template Goal", name, "kra", kra_title, update_modified=False)
# set 140 char kra in the `key_result_area` field
frappe.db.set_value(
"Appraisal Template Goal", name, "key_result_area", kra_title, update_modified=False
)

if frappe.db.auto_commit_on_many_writes:
frappe.db.auto_commit_on_many_writes = 0
Expand Down
Loading

0 comments on commit 3ba4182

Please sign in to comment.