Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expire_allocation api endpoint by fetching allocation object #1576

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

zeel-codder
Copy link
Contributor

Add the code to fetch allocation in expire_allocation endpoint so that after code not break.

Traceback of error which is fixed

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 1682, 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/hr/doctype/leave_ledger_entry/leave_ledger_entry.py", line 193, in expire_allocation
    leaves = get_remaining_leaves(allocation)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/hrms/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry.py", line 178, in get_remaining_leaves
    "employee": allocation.employee,
                ^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'employee'

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 72.80%. Comparing base (8f6e819) to head (5a1bcac).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1576      +/-   ##
===========================================
- Coverage    72.85%   72.80%   -0.05%     
===========================================
  Files          202      202              
  Lines        11169    11173       +4     
===========================================
- Hits          8137     8135       -2     
- Misses        3032     3038       +6     
Files Coverage Δ
...r/doctype/leave_ledger_entry/leave_ledger_entry.py 88.05% <50.00%> (-2.42%) ⬇️

... and 2 files with indirect coverage changes

Copy link
Collaborator

@krantheman krantheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this?

hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry.py Outdated Show resolved Hide resolved
@zeel-codder
Copy link
Contributor Author

Can you add a test for this?

Yes, will add.

@zeel-codder
Copy link
Contributor Author

@krantheman I have added the test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants