Skip to content

Commit

Permalink
feat: validate overlapping dates
Browse files Browse the repository at this point in the history
(cherry picked from commit a3f830e)
  • Loading branch information
krantheman authored and mergify[bot] committed Dec 7, 2023
1 parent d18c4f4 commit d8f0adb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hrms/hr/doctype/shift_assignment/shift_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ def validate_overlapping_shifts(self):
self.throw_overlap_error(overlapping_dates[0])

def validate_multiple_shift_assignments(self):
overlapping_dates = self.get_overlapping_dates()
if not len(overlapping_dates):
return

allow_multiple_shift_assignments = frappe.db.get_single_value(
"HR Settings", "allow_multiple_shift_assignments"
)
if not allow_multiple_shift_assignments:
frappe.throw(
_(
"Multiple shift assignments for the same date has been disabled. Please enable this feature in the {0}."
"Multiple shift assignments for the same date has been disabled. Please enable this feature under {0}."
).format(get_link_to_form("HR Settings", "HR Settings"))
)

frappe.msgprint(
_(
"Note: You have already assigned different Shifts to {0} for some/all of these dates. Multiple Shift Assignments for the same date can be disabled in the {1}."
"Note: You have already assigned different Shifts to {0} for some/all of these dates. Multiple Shift Assignments for the same date can be disabled under {1}."
).format(self.employee, get_link_to_form("HR Settings", "HR Settings"))
)

Expand Down

0 comments on commit d8f0adb

Please sign in to comment.