From 9b313b28e71b6704855e869940b31f2b08fccb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 17 Jul 2023 09:48:45 +0000 Subject: [PATCH] [FIX] event_crm: avoid formatting issues in generated description Avoid issues when generating lead description based on linked registrations notably with formatted emails. Task-3431124 X-original-commit: 471025a7bd227d334ac5b450c93a2ee99c22517a Part-of: odoo/odoo#129269 --- addons/event_crm/models/event_registration.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/event_crm/models/event_registration.py b/addons/event_crm/models/event_registration.py index b71a2e42906..1abca8f3602 100644 --- a/addons/event_crm/models/event_registration.py +++ b/addons/event_crm/models/event_registration.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from collections import defaultdict +from markupsafe import Markup from odoo import api, fields, models, tools, _ from odoo.addons.phone_validation.tools import phone_validation @@ -255,17 +256,21 @@ class EventRegistration(models.Model): line_suffix=line_suffix ) for registration in self ] - return ("%s
" % prefix if prefix else "") + ( - "
    " if line_counter else "
" if line_counter else "") + description = (prefix if prefix else '') + Markup("
") + if line_counter: + description += Markup("
    ") + Markup('').join(reg_lines) + Markup("
") + else: + description += Markup("") + return description def _get_lead_description_registration(self, line_suffix=''): """ Build the description line specific to a given registration. """ self.ensure_one() - return "
  • %s (%s)%s
  • " % ( + return Markup("
  • ") + "%s (%s)%s" % ( self.name or self.partner_id.name or self.email, " - ".join(self[field] for field in ('email', 'phone') if self[field]), - " %s" % line_suffix if line_suffix else "", - ) + f" {line_suffix}" if line_suffix else "", + ) + Markup("
  • ") def _get_lead_tracked_values(self): """ Tracked values are based on two subset of fields to track in order