From 51b36f2463ca914cddfb87794ab7d00f2e73bcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 12 Feb 2025 13:26:01 +0100 Subject: [PATCH 1/2] [IMP] rma: Add Markup to messages to display the html code correctly TT54263 --- rma/models/rma.py | 57 +++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/rma/models/rma.py b/rma/models/rma.py index c2ce1c20..316f125a 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -1,11 +1,14 @@ # Copyright 2020 Tecnativa - Ernesto Tejeda # Copyright 2023 Tecnativa - Pedro M. Baeza # Copyright 2023 Michael Tietz (MT Software) +# Copyright 2025 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import logging from collections import defaultdict from itertools import groupby +from markupsafe import Markup + from odoo import _, api, fields, models from odoo.exceptions import AccessError, ValidationError from odoo.tools import html2plaintext @@ -981,11 +984,13 @@ class Rma(models.Model): subtype_id=self.env["ir.model.data"]._xmlid_to_res_id("mail.mt_note"), ) self.message_post( - body=_( - 'Split: %(name)s has been created.' + body=Markup( + _( + 'Split: %(name)s has been created.' + ) + % ({"id": extracted_rma.id, "name": extracted_rma.name}) ) - % ({"id": extracted_rma.id, "name": extracted_rma.name}) ) return extracted_rma @@ -1115,11 +1120,13 @@ class Rma(models.Model): picking = rma.delivery_move_ids.picking_id.sorted("id", reverse=True)[0] pickings[picking] |= rma rma.message_post( - body=_( - 'Return: %(name)s has been created.' + body=Markup( + _( + 'Return: %(name)s has been created.' + ) + % ({"id": picking.id, "name": picking.name}) ) - % ({"id": picking.id, "name": picking.name}) ) for picking, rmas in pickings.items(): picking.action_confirm() @@ -1183,7 +1190,7 @@ class Rma(models.Model): # The product replacement could explode into several moves like in the case of # MRP BoM Kits for new_move in new_moves: - body += ( + body += Markup( _( 'Replacement: Move %(move_name)s (Picking " - 'Product %(name)s
' - "Quantity %(qty)s %(uom)s
" - "This replacement did not create a new move, but one of " - "the previously created moves was updated with this data." - ) - % ( - { - "id": self.id, - "name": self.display_name, - "qty": qty, - "uom": uom.name, - } + or Markup( + _( + "Replacement:
" + 'Product %(name)s
' + "Quantity %(qty)s %(uom)s
" + "This replacement did not create a new move, but one of " + "the previously created moves was updated with this data." + ) + % ( + { + "id": self.product_id.id, + "name": self.product_id.display_name, + "qty": qty, + "uom": uom.name, + } + ) ) ) From 2864650c0b130cfbe94cbbe06522e647639dcbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 12 Feb 2025 13:37:35 +0100 Subject: [PATCH 2/2] [FIX] rma: Change remaining_qty_to_done to remaining_qty field The remaining_qty_to_done field was removed in https://github.com/OCA/rma/commit/9cc5bca1532edc9c8de4fd2e0d0a6cb4e0bb8161 --- rma/models/rma.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/rma/models/rma.py b/rma/models/rma.py index 316f125a..41e2d9ee 100644 --- a/rma/models/rma.py +++ b/rma/models/rma.py @@ -306,16 +306,10 @@ class Rma(models.Model): @api.depends("product_uom_qty", "delivered_qty") def _compute_remaining_qty(self): - """Compute 'remaining_qty' and 'remaining_qty_to_done' fields. + """Compute 'remaining_qty' field. remaining_qty: is used to set a default quantity of replacing or returning of product to the customer. - - remaining_qty_to_done: the aim of this field to control when the - RMA cam be set to 'delivered' state. An RMA with - remaining_qty_to_done <= 0 can be set to 'delivery'. It is used - in stock.move._action_done method of stock.move and - rma.extract_quantity. """ for r in self: r.remaining_qty = r.product_uom_qty - r.delivered_qty @@ -380,7 +374,7 @@ class Rma(models.Model): for r in self: if r.product_uom_qty > 1 and ( (r.state == "waiting_return" and r.remaining_qty > 0) - or (r.state == "waiting_replacement" and r.remaining_qty_to_done > 0) + or (r.state == "waiting_replacement" and r.remaining_qty > 0) ): r.can_be_split = True else: