[IMP] sale: amount_to_invoice set to 0 if fully invoiced

For sale orders, if the invoice status is set to "Fully Invoiced", the mount to invoice is forced to zero.

task-3347812

closes odoo/odoo#124777

Signed-off-by: Quentin De Paoli <qdp@odoo.com>
This commit is contained in:
Ali Alfie (alal)
2023-07-26 23:15:03 +02:00
parent 8da5cdf5c0
commit 5b607e5a0b
+5
View File
@@ -611,6 +611,11 @@ class SaleOrder(models.Model):
@api.depends('invoice_ids.state', 'currency_id', 'amount_total')
def _compute_amount_to_invoice(self):
for order in self:
# If the invoice status is 'Fully Invoiced' force the amount to invoice to equal zero and return early.
if order.invoice_status == 'invoiced':
order.amount_to_invoice = 0.0
return
order.amount_to_invoice = order.amount_total
for invoice in order.invoice_ids.filtered(lambda x: x.state == 'posted'):
invoice_amount_currency = invoice.currency_id._convert(