-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Module
sale_advance_payment
Describe the bug
The amount_residual field in sales orders shows an incorrect value when there are refund invoices (credit notes) associated with the order. This happens because the current calculation doesn't properly handle the sign of refund invoices.
To Reproduce
Affected versions: 16.0
Steps to reproduce the behavior:
- Create a sales order
- Confirm the order and create the customer invoice
- Post the invoice
- Ceate a refund invoice (credit note)
- Post the refund invoice
- Check the amount_residual field in the sales order
Expected behavior
The amount_residual should correctly reflect the actual pending amount, properly accounting for both the original invoice and the refund invoice with their corresponding signs.
Additional context
The issue appears to be in the computation logic at: https://github.com/OCA/sale-workflow/blob/16.0/sale_advance_payment/models/sale.py#L57
The calculation should use amount_residual_signed instead of amount_residual to properly handle the sign of refund invoices.
Example runboat scenario:
Related PR: #3863