From 48a591c40995ade34bf815c7bf8e09b3ffa56bb8 Mon Sep 17 00:00:00 2001 From: dht-odoo Date: Tue, 15 Jun 2021 08:49:42 +0000 Subject: [PATCH] [FIX] repair: fix html formatting in narration Followup of odoo/odoo@cb4f597410bcb08208ee277144d755bef8b6d688 and odoo/enterprise@971f3ed9ae89e965e4c6d2d0b6d26719d694ddc1 We have converted string into markup string in repair as we cannot concatenate strings directly to Markup string. And if we try to do it we will see the html elements '
' in field value, so we have to convert '
' string into markup language to avoid this. Also avoid adding pseudo-void html content in narration. LINKS Task Id-2558824 PR odoo/odoo#74795 PR odoo/enterprise#20117 --- addons/repair/models/repair.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 25443b46ce8..62b798c0081 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -3,9 +3,11 @@ from collections import defaultdict from random import randint +from markupsafe import Markup + from odoo import api, fields, models, _ from odoo.exceptions import UserError, ValidationError -from odoo.tools import float_compare +from odoo.tools import float_compare, is_html_empty class StockMove(models.Model): @@ -344,7 +346,7 @@ class Repair(models.Model): 'partner_id': partner_invoice.id, 'partner_shipping_id': repair.address_id.id, 'currency_id': currency.id, - 'narration': narration, + 'narration': narration if not is_html_empty(narration) else '', 'invoice_origin': repair.name, 'repair_ids': [(4, repair.id)], 'invoice_line_ids': [], @@ -358,10 +360,11 @@ class Repair(models.Model): invoice_vals = current_invoices_list[0] invoice_vals['invoice_origin'] += ', ' + repair.name invoice_vals['repair_ids'].append((4, repair.id)) - if not invoice_vals['narration']: - invoice_vals['narration'] = narration - else: - invoice_vals['narration'] += '
' + narration + if not is_html_empty(narration): + if is_html_empty(invoice_vals['narration']): + invoice_vals['narration'] = narration + else: + invoice_vals['narration'] += Markup('
') + narration # Create invoice lines from operations. for operation in repair.operations.filtered(lambda op: op.type == 'add'):