From 5b607e5a0bc0a01759fb686895058bd310301cbb Mon Sep 17 00:00:00 2001 From: "Ali Alfie (alal)" Date: Mon, 12 Jun 2023 12:40:11 +0000 Subject: [PATCH] [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 --- addons/sale/models/sale_order.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index 9d99bf719f0..1792b01dbf8 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -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(