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

Return_amount not assigned: AttributeError: 'ExpenseClaimAdvance' object has no attribute 'return_amount' #2881

Open
1 task done
chillylin opened this issue Mar 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@chillylin
Copy link

Information about bug

Variable d.return_amount is not properly assigned with value.

Line 351 of https://github.com/frappe/hrms/blob/develop/hrms/hr/doctype/expense_claim/expense_claim.py

flt(d.unclaimed_amount) - flt(d.return_amount)

The line uses a variable d.return_amount before assigning a value to it ( presumably from ref_doc.return_amount )

I changed line 351 to flt(d.unclaimed_amount) - flt(ref_doc.return_amount) and the bug disappeared, but I guess it is more elegant to add a line d.return_amount = ref_doc.return_amount before line 351.

Thank you very reading.

Module

HR

Version

"ecommerce_integrations": "1.20.1",
"erpnext": "15.53.2",
"frappe": "15.56.1",
"hrms": "15.40.0",
"payments": "0.0.1"

Installation method

None

Relevant log output / Stack trace / Full Error Message.

### Route

Form/Expense Claim/HR-EXP-2025-00368

### Traceback

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 50, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1726, 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/desk/form/save.py", line 37, in savedocs
    doc.submit()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1060, in submit
    return self._submit()
           ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1043, in _submit
    return self.save()
           ^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 342, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 378, in _save
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1106, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 974, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1334, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1316, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 971, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/hrms/hrms/hr/doctype/expense_claim/expense_claim.py", line 50, in validate
    self.validate_advances()
  File "apps/hrms/hrms/hr/doctype/expense_claim/expense_claim.py", line 351, in validate_advances
    flt(d.unclaimed_amount) - flt(d.return_amount)
                                  ^^^^^^^^^^^^^^^
AttributeError: 'ExpenseClaimAdvance' object has no attribute 'return_amount'

### Response Data

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

Code of Conduct

  • I agree to follow this project's Code of Conduct
@chillylin chillylin added the bug Something isn't working label Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant