From 431d4275132c2861befd663a8c24177188417e68 Mon Sep 17 00:00:00 2001 From: Alessandro Fiorino Date: Thu, 25 Apr 2024 15:15:24 +0200 Subject: [PATCH] [16.0][IMP] sale_force_invoiced: update untaxed_amount_to_invoice Recompute untaxed_amount_to_invoice on the sale order lines when force_invoiced is changed. --- sale_force_invoiced/models/sale_order.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sale_force_invoiced/models/sale_order.py b/sale_force_invoiced/models/sale_order.py index c3ce8262f79..d847f5c6bd8 100644 --- a/sale_force_invoiced/models/sale_order.py +++ b/sale_force_invoiced/models/sale_order.py @@ -24,3 +24,14 @@ def _compute_invoice_status(self): lambda so: so.force_invoiced and so.state in ("sale", "done") ).update({"invoice_status": "invoiced"}) return res + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + @api.depends("order_id.force_invoiced") + def _compute_untaxed_amount_to_invoice(self): + force_invoiced = self.filtered(lambda x: x.order_id.force_invoiced) + force_invoiced.update({"untaxed_amount_to_invoice": 0.0}) + not_forced = self - force_invoiced + return super(SaleOrderLine, not_forced)._compute_untaxed_amount_to_invoice()