OpenUpgrade icon indicating copy to clipboard operation
OpenUpgrade copied to clipboard

[15.0][OU-FIX] fix hr.expense account.move and lines

Open huguesdk opened this issue 4 months ago • 0 comments

fix the value of several fields on account.move and account.move.line records linked to hr.expense records.

this computes account.move.line.exclude_from_invoice_tab differently than #4386 did. the goal remains the same: it should be true for destination lines. the code was assuming that destination lines where the ones with a quantity of 0, but this does not work, as odoo 14 does not set a quantity on those lines and the default value for this field is 1. instead, this field is computed by checking that the account is of type "payable".

with exclude_from_invoice_tab correctly set, it is now safe to call account.move._compute_amount() to correctly recompute several fields (always_tax_exigible, amount_residual, amount_residual_signed, amount_untaxed, amount_untaxed_signed, payment_state) of the account.move without changing accounting data. account.move.write() checks that reconciled moves are not changed, and with this code, it succeeds.

this code also recomputes these fields for account.move records not directly linked to hr.expense.sheet records, but linked to an hr.expense record through their account.move.line records, since this is how account.move._payment_state_matters() selects the records.

huguesdk avatar Oct 04 '24 08:10 huguesdk