From 43563dd9ebbf4aa8cde656726e1adb7351c8c657 Mon Sep 17 00:00:00 2001 From: Martin Quinteros Date: Mon, 18 Aug 2025 15:12:02 +0000 Subject: [PATCH] [IMP] sale_ux: Unlink inactive tax id on duplicate sale order X-original-commit: 4d5930ea2658a5336b83822bb73357c7949bf80b --- sale_ux/models/sale_order.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sale_ux/models/sale_order.py b/sale_ux/models/sale_order.py index 097bcfc61..6506d3d5e 100644 --- a/sale_ux/models/sale_order.py +++ b/sale_ux/models/sale_order.py @@ -4,7 +4,7 @@ ############################################################################## from datetime import timedelta -from odoo import _, api, fields, models +from odoo import Command, _, api, fields, models from odoo.exceptions import UserError, ValidationError from odoo.tools import float_is_zero from odoo.tools.safe_eval import safe_eval @@ -263,6 +263,8 @@ def copy(self, default=None): "" if not old_order else _("This sale order was duplicated from %s", old_order._get_html_link()) ) new_orders._message_log_batch(bodies=bodies) + for line_to_clean in new_orders.mapped("order_line").filtered(lambda x: False in x.mapped("tax_id.active")): + line_to_clean.tax_id = [Command.unlink(x.id) for x in line_to_clean.tax_id.filtered(lambda x: not x.active)] return new_orders @api.depends("force_invoiced_status")