From 65782dfe74f3d85fe02ac03b33af4a2ae106d72e Mon Sep 17 00:00:00 2001 From: krantheman Date: Thu, 27 Jun 2024 14:40:45 +0530 Subject: [PATCH] refactor(Shift Assignment Schedule): change Status to Enabled --- hrms/api/roster.py | 2 +- .../shift_assignment_schedule.json | 39 +++++++++---------- .../shift_assignment_schedule.py | 2 +- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/hrms/api/roster.py b/hrms/api/roster.py index 344678b09c..5a363068fc 100644 --- a/hrms/api/roster.py +++ b/hrms/api/roster.py @@ -46,7 +46,7 @@ def create_shift_assignment_schedule( "doctype": "Shift Assignment Schedule", "frequency": frequency, "repeat_on_days": [{"day": day} for day in repeat_on_days], - "status": "Inactive" if end_date else "Active", + "enabled": 0 if end_date else 1, "employee": employee, "company": company, "shift_type": shift_type, diff --git a/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.json b/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.json index d83e21de4b..e60f62bce1 100644 --- a/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.json +++ b/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.json @@ -9,7 +9,7 @@ "frequency", "repeat_on_days", "column_break_iprq", - "status", + "enabled", "create_shifts_after", "shift_details_section", "employee", @@ -32,17 +32,6 @@ "options": "Every Week\nEvery 2 Weeks\nEvery 3 Weeks\nEvery 4 Weeks", "reqd": 1 }, - { - "default": "Active", - "description": "Select 'Active' if you want new shift assignments to be created automatically.", - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Status", - "options": "Active\nInactive", - "reqd": 1 - }, { "fieldname": "shift_details_section", "fieldtype": "Section Break", @@ -57,10 +46,12 @@ "reqd": 1 }, { + "fetch_from": "employee.company", "fieldname": "company", "fieldtype": "Link", "label": "Company", "options": "Company", + "read_only": 1, "reqd": 1 }, { @@ -76,12 +67,6 @@ "options": "Shift Type", "reqd": 1 }, - { - "fieldname": "shift_status", - "fieldtype": "Select", - "label": "Shift Status", - "options": "Active\nInactive" - }, { "fieldname": "schedule_settings_section", "fieldtype": "Section Break" @@ -95,7 +80,7 @@ }, { "default": "Today", - "depends_on": "eval:doc.status === 'Active'", + "depends_on": "eval:doc.enabled", "description": "New shift assignments will be created after this date.", "fieldname": "create_shifts_after", "fieldtype": "Date", @@ -108,6 +93,20 @@ "label": "Repeat On Days", "options": "Assignment Rule Day", "reqd": 1 + }, + { + "default": "1", + "description": "Select this if you want shift assignments to be automatically created indefinitely.", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled" + }, + { + "default": "Active", + "fieldname": "shift_status", + "fieldtype": "Select", + "label": "Status", + "options": "Active\nInactive" } ], "index_web_pages_for_search": 1, @@ -117,7 +116,7 @@ "link_fieldname": "schedule" } ], - "modified": "2024-06-25 16:49:16.848569", + "modified": "2024-06-27 14:37:31.797684", "modified_by": "Administrator", "module": "HR", "name": "Shift Assignment Schedule", diff --git a/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.py b/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.py index 1b613d0f6b..84c31ea3d6 100644 --- a/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.py +++ b/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.py @@ -56,7 +56,7 @@ def create_individual_assignment(self, start_date, end_date): def process_auto_shift_creation(): schedules = frappe.get_all( "Shift Assignment Schedule", - filters={"status": "Active", "create_shifts_after": ["<=", nowdate()]}, + filters={"enabled": 1, "create_shifts_after": ["<=", nowdate()]}, pluck="name", ) for d in schedules: