fix(Expense Claim): get_taxes condition (backport #2077) #2079
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
After adding a few rows in the expenses table, new ones randomly become uneditable.
Investigation
It seems to occur because of the following code, which is executed every time the sanctioned amount in an expense is updated. Not entirely sure why, but turns out that making any server side call causes this to happen.
Temporary Solution
The
get_taxes
function is meant to run only if there are taxes added in the expense claim document. However, an empty array being a truthy value,frm.doc.taxes
inif (frm.doc.taxes)
always returnstrue
and this call is made for every expense.Fixing this condition, at the very least, prevents this issue from occurring for most users (who I'm guessing add their taxes after their expenses). However, a more universal fix, involving business logic refactoring, may be in order.
This is an automatic backport of pull request #2077 done by Mergify.