frappe / hrms

Open Source HR and Payroll Software
https://frappe.io/hr
GNU General Public License v3.0
1.39k stars 732 forks source link

Shift Type gives error while process the attendance #1838

Closed dineshpanchal93 closed 5 months ago

dineshpanchal93 commented 5 months ago

Information about bug

Shift Type gives error while process the attendance

Module

HR

Version

ERPNext: v15.20.5 (version-15)

Frappe Framework: v15.23.0 (version-15)

Hr Reports: v0.0.1 (main)

Frappe HR: v15.18.0 (version-15)

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

Traceback with variables (most recent call last):
  File "apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py", line 143, in execute
    frappe.get_attr(self.method)()
      self = <ScheduledJobType: shift_type.process_auto_attendance_for_all_shifts>
  File "apps/hrms/hrms/hr/doctype/shift_type/shift_type.py", line 297, in process_auto_attendance_for_all_shifts
    doc.process_auto_attendance()
      shift_list = ['Manegerial Staff', 'Production Staff', 'Office Staff']
      shift = 'Production Staff'
      doc = <ShiftType: Production Staff>
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
      args = (<ShiftType: Production Staff>,)
      kwargs = {}
      apply_condition = <function whitelist.<locals>.innerfn.<locals>.<lambda> at 0x7fa578b6f130>
      func = <function ShiftType.process_auto_attendance at 0x7fa578b6f0a0>
  File "apps/hrms/hrms/hr/doctype/shift_type/shift_type.py", line 41, in process_auto_attendance
    attendance_date = key[1].date()
      self = <ShiftType: Production Staff>
      logs = [{'name': 'EMP-CKIN-05-2024-003128', 'employee': 'HR-EMP-00015', 'log_type': 'IN', 'time': datetime.datetime(2024, 5, 17, 8, 30), 'shift': 'Production Staff', 'shift_start': datetime.datetime(2024, 5, 17, 9, 0), 'shift_end': datetime.datetime(2024, 5, 17, 19, 0), 'shift_actual_start': datetime.datetime(2024, 5, 17, 4, 0), 'shift_actual_end': datetime.datetime(2024, 5, 18, 0, 0), 'device_id': None}, {'name': 'EMP-CKIN-05-2024-003067', 'employee': 'HR-EMP-00015', 'log_type': '', 'time': datetime.datetime(2024, 5, 28, 7, 21, 2), 'shift': 'Production Staff', 'shift_start': datetime.datetime(2024, 5, 28, 9, 0), 'shift_end': datetime.datetime(2024, 5, 28, 19, 0), 'shift_actual_start': datetime.datetime(2024, 5, 28, 4, 0), 'shift_actual_end': datetime.datetime(2024, 5, 29, 0, 0), 'device_id': '1'}, {'name': 'EMP-CKIN-05-2024-003068', 'employee': 'HR-EMP-00015', 'log_type': '', 'time': datetime.datetime(2024, 5, 28, 7, 21, 4), 'shift': 'Production Staff', 'shift_start': datetime.datetime(2024,...
      key = ********
      group = <itertools._grouper object at 0x7fa5788a4f40>
      single_shift_logs = [{'name': 'EMP-CKIN-05-2024-003129', 'employee': 'HR-EMP-00026', 'log_type': 'IN', 'time': datetime.datetime(2024, 5, 27, 9, 0), 'shift': 'Production Staff', 'shift_start': None, 'shift_end': None, 'shift_actual_start': None, 'shift_actual_end': None, 'device_id': None}]
      attendance_date = datetime.date(2024, 5, 30)
      employee = 'HR-EMP-00023'
      attendance_status = 'Present'
      working_hours = 11.47
      late_entry = False
      early_exit = False
      in_time = datetime.datetime(2024, 5, 30, 9, 1, 22)
      out_time = datetime.datetime(2024, 5, 30, 20, 29, 50)
builtins.AttributeError: 'NoneType' object has no attribute 'date'

Code of Conduct

dineshpanchal93 commented 5 months ago

App Versions

{
    "auto_codification": "0.0.1",
    "bhagwati_addon_s": "0.0.1",
    "erpnext": "15.20.5",
    "frappe": "15.23.0",
    "hr_reports": "0.0.1",
    "hrms": "15.18.0",
    "in_out_track": "0.0.1",
    "india_compliance": "15.7.2",
    "print_designer": "1.2.0",
    "sbi": "0.0.1"
}

Route

Form/Shift Type/Production Staff

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, 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
    return frappe.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 1718, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/handler.py", line 326, in run_doc_method
    response = doc.run_method(method)
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/hrms/hrms/hr/doctype/shift_type/shift_type.py", line 41, in process_auto_attendance
    attendance_date = key[1].date()
AttributeError: 'NoneType' object has no attribute 'date'

Request Data

{
    "type": "POST",
    "args": {
        "docs": "{\"name\":\"Production Staff\",\"owner\":\"Administrator\",\"creation\":\"2023-12-27 11:11:25.406764\",\"modified\":\"2024-05-31 12:38:06.428196\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":577,\"start_time\":\"9:00:00\",\"end_time\":\"19:00:00\",\"holiday_list\":\"Holiday List 2024\",\"enable_auto_attendance\":1,\"determine_check_in_and_check_out\":\"Alternating entries as IN and OUT during the same shift\",\"working_hours_calculation_based_on\":\"First Check-in and Last Check-out\",\"begin_check_in_before_shift_start_time\":300,\"allow_check_out_after_shift_end_time\":300,\"mark_auto_attendance_on_holidays\":1,\"working_hours_threshold_for_half_day\":0,\"working_hours_threshold_for_absent\":2,\"process_attendance_after\":\"2024-02-28\",\"last_sync_of_checkin\":\"2024-05-30 23:59:59\",\"enable_late_entry_marking\":1,\"late_entry_grace_period\":15,\"enable_early_exit_marking\":1,\"early_exit_grace_period\":15,\"doctype\":\"Shift Type\"}",
        "method": "process_auto_attendance"
    },
    "freeze": true,
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/run_doc_method",
    "request_id": null
}

Response Data

{
    "exception": "AttributeError: 'NoneType' object has no attribute 'date'",
    "exc_type": "AttributeError",
    "_exc_source": "hrms (app)"
}