You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In roster i wanted to assign an employee to a new shift but when i assign him within a week it is working fine . But when the start and end date difference is more than a week It shows up with an error .
Module
HR
Version
erpnext 15.41.0
frappe 15.47.0
hrms 15.34.0
Installation method
manual install
Relevant log output / Stack trace / Full Error Message.
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 114, in application
response = frappe.api.handle(request)
File "apps/frappe/frappe/api/__init__.py", line 49, in handle
data = endpoint(**arguments)
File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
returnfrappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 49, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1781, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(*args, **kwargs)
File "apps/hrms/hrms/api/roster.py", line 59, in create_shift_assignment_schedule
return schedule.create_shifts(start_date, end_date)
File "apps/hrms/hrms/hr/doctype/shift_assignment_schedule/shift_assignment_schedule.py", line 22, in create_shifts
week_end_day = get_weekday(add_days(start_date, -1))
File "apps/frappe/frappe/utils/data.py", line 716, in get_weekday
returnweekdays[datetime.weekday()]
AttributeError: 'str' object has no attribute 'weekday'
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
index-B9DvsdXp.js:175 Uncaught (in promise) Error: /api/method/hrms.api.roster.create_shift_assignment_schedule AttributeError
at index-B9DvsdXp.js:175:1686
at Generator.next (<anonymous>)
at i (index-B9DvsdXp.js:2:668)
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
in the create shifts function get_weekday() accepts a date time object but a string was passed . i altered the code for testing and it is working. but i dont no if it will effect in any other section .
`
def create_shifts(self, start_date: str, end_date: str | None = None) -> None:
gap = {
"Every Week": 0,
"Every 2 Weeks": 1,
"Every 3 Weeks": 2,
"Every 4 Weeks": 3,
}[self.frequency]
date = start_date
individual_assignment_start = None
# Convert the result of add_days to a date object
week_end_day = get_weekday(getdate(add_days(start_date, -1)))
repeat_on_days = [day.day for day in self.repeat_on_days]
if not end_date:
end_date = add_days(start_date, 90)
while date <= end_date:
# Convert date string to date object before getting weekday
weekday = get_weekday(getdate(date))
if weekday in repeat_on_days:
if not individual_assignment_start:
individual_assignment_start = date
if date == end_date:
self.create_individual_assignment(individual_assignment_start, date)
elif individual_assignment_start:
self.create_individual_assignment(individual_assignment_start, add_days(date, -1))
individual_assignment_start = None
if weekday == week_end_day and gap:
if individual_assignment_start:
self.create_individual_assignment(individual_assignment_start, date)
individual_assignment_start = None
date = add_days(date, 7 * gap)
date = add_days(date, 1)
Information about bug
In roster i wanted to assign an employee to a new shift but when i assign him within a week it is working fine . But when the start and end date difference is more than a week It shows up with an error .
Module
HR
Version
erpnext 15.41.0
frappe 15.47.0
hrms 15.34.0
Installation method
manual install
Relevant log output / Stack trace / Full Error Message.
Code of Conduct
The text was updated successfully, but these errors were encountered: