From 65c47d860ea9247f47bcd5cbac2acf2acf50afa3 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/__init__.py | 1 + sale_force_invoiced/models/sale_order_line.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 sale_force_invoiced/models/sale_order_line.py diff --git a/sale_force_invoiced/models/__init__.py b/sale_force_invoiced/models/__init__.py index b1ad204bdec2..87674023e660 100644 --- a/sale_force_invoiced/models/__init__.py +++ b/sale_force_invoiced/models/__init__.py @@ -1,3 +1,4 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import sale_order +from . import sale_order_line diff --git a/sale_force_invoiced/models/sale_order_line.py b/sale_force_invoiced/models/sale_order_line.py new file mode 100644 index 000000000000..28c681e16bc0 --- /dev/null +++ b/sale_force_invoiced/models/sale_order_line.py @@ -0,0 +1,15 @@ +# Copyright 2017 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +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()