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

Error on Submitting Employee Claims #1936

Closed harveybalce closed 4 months ago

harveybalce commented 4 months ago

Information about bug

Error deleting and submitting expense claims Error Says: "Approval Status must be 'Approved' or 'Rejected' ".

Module

HR

Version

ERPNext: v15.28.2 (HEAD) Frappe Framework: v15.32.0 (HEAD) Frappe HR: v15.23.0 (HEAD)

Installation method

FrappeCloud

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
    "builder": "1.10.0",
    "desk_navbar_extended": "0.0.1",
    "erpnext": "15.28.2",
    "frappe": "15.32.0",
    "hrms": "15.23.0",
    "insights": "2.2.2",
    "payments": "0.0.1",
    "print_designer": "1.3.3",
    "webshop": "0.0.1",
    "wiki": "2.0.0"
}

Route

Form/Expense Claim/HR-EXP-2024-00020

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/email/doctype/notification/notification.py", line 493, in evaluate_alert
    fieldtype = doc.meta.get_field(alert.value_changed).fieldtype
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'fieldtype'

During handling of the above exception, another exception occurred:

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
    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 1768, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/client.py", line 275, in delete
    delete_doc(doctype, name)
  File "apps/frappe/frappe/client.py", line 506, in delete_doc
    frappe.delete_doc(doctype, name, ignore_missing=False)
  File "apps/frappe/frappe/__init__.py", line 1392, in delete_doc
    return frappe.model.delete_doc.delete_doc(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/delete_doc.py", line 126, in delete_doc
    doc.run_method("on_change")
  File "apps/frappe/frappe/model/document.py", line 964, in run_method
    self.run_notifications(method)
  File "apps/frappe/frappe/model/document.py", line 1024, in run_notifications
    _evaluate_alert(alert)
  File "apps/frappe/frappe/model/document.py", line 1007, in _evaluate_alert
    evaluate_alert(self, alert.name, alert.event)
  File "apps/frappe/frappe/email/doctype/notification/notification.py", line 512, in evaluate_alert
    msg = f"<details><summary>{title}</summary>{message}</details>"
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'message' where it is not associated with a value

Request Data

{
    "type": "POST",
    "args": {
        "doctype": "Expense Claim",
        "name": "HR-EXP-2024-00020"
    },
    "freeze": true,
    "freeze_message": "Deleting HR-EXP-2024-00020...",
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.client.delete",
    "request_id": "ea80f41b-35bd-4c13-ba63-0eaa59041670"
}

Response Data

{
    "exception": "UnboundLocalError: cannot access local variable 'message' where it is not associated with a value",
    "exc_type": "UnboundLocalError"
}

Traceback with variables (most recent call last): File "apps/frappe/frappe/email/doctype/notification/notification.py", line 493, in evaluate_alert fieldtype = doc.meta.get_field(alert.value_changed).fieldtype doc = alert = event = 'Value Change' TemplateError = <class 'jinja2.exceptions.TemplateError'> context = {'doc': , 'nowdate': <function nowdate at 0x7f7afcc24b80>, 'frappe': {'utils': {'DATE_FORMAT': '%Y-%m-%d', 'TIME_FORMAT': '%H:%M:%S.%f', 'DATETIME_FORMAT': '%Y-%m-%d %H:%M:%S.%f', 'is_invalid_date_string': <function is_invalid_date_string at 0x7f7afcc13b00>, 'getdate': <function getdate at 0x7f7afcc13c40>, 'get_datetime': <function get_datetime at 0x7f7afcc13ba0>, 'get_timedelta': <function get_timedelta at 0x7f7afcc13ce0>, 'to_timedelta': <function to_timedelta at 0x7f7afcc13d80>, 'add_to_date': <function add_to_date at 0x7f7afcc240e0>, 'add_days': <function add_days at 0x7f7afcc24180>, 'add_months': <function add_months at 0x7f7afcc24220>, 'add_years': <function add_years at 0x7f7afcc242c0>, 'date_diff': <function date_diff at 0x7f7afcc24360>, 'month_diff': <function month_diff at 0x7f7afcc24400>, 'time_diff': <function time_diff at 0x7f7afcc244a0>, 'time_diff_in_seconds': <function time_diff_in_seconds at 0x7f7afcc24540>, 'time_diff_in_hours': <funct... doc_before_save = None field_value_before_save = None e = AttributeError("'NoneType' object has no attribute 'fieldtype'") title = "'NoneType' object has no attribute 'fieldtype'" builtins.AttributeError: 'NoneType' object has no attribute 'fieldtype'



### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
SalahAddinAbdo commented 4 months ago

Same Error Here in expense claims Error Says: "Approval Status must be 'Approved' or 'Rejected' ".

Self Hosted

Erpnext 15.28.2 Frappe 15.32.0 hrms 15.23.0

Nihantra-Patel commented 4 months ago

It's not an error because if you add expense approval within employee, the permission level one does not have rights. So you don't see the status. If he has field permission rights, he can approve, otherwise he can't.

image

sammish commented 4 months ago

@Nihantra-Patel Thanks