Usecase to reproduce:
- Set stock valuation as perpetual
- Create a PO with a different currency than the company
- Validate the receipt on create the invoice
- Set a discount on the invoice and validate it
The amount currency is not set on the account.move.line created by the
valuation layer. It could prevent the reconciliation to succeed since
it would be base on invoice currency.
It happens because the amount currency is created from the difference
between layer price converted to invoice currency and the invoice line
`price_unit`. However `price_unit` is missing the discount. So this pr
add extra computation to get the gross price unit discount applied.
closesodoo/odoo#107256
X-original-commit: 493020b9317a439c0a61a34f37cc92b6779ef633
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>