From 5b854f7f5f4aff7101655b46667f2f17a635aa00 Mon Sep 17 00:00:00 2001 From: thcl-odoo Date: Mon, 20 Dec 2021 15:16:19 +0000 Subject: [PATCH] [FIX] web: match downloaded pdf with preview Current behavior : PDF Preview in document layout settings doesn't match the downloaded one (colors of div with the total and the columns displayed) Steps to reproduce : - Go to Settings - 'Configure Document Layout' under Companies - Set layout to Boxed - Change the colors - Download the PDF Preview Reason : - The columns for the unit price and taxes had the 'd-none' class so they weren't visible when printing the pdf preview. To keep coherence, if we see them in the preview we must see them in the pdf. - Colors, especially the total div with a 'Boxed' layout, weren't taken into account for some elements in the preview. This is due to a character sanitized in the CSS, specifically '>' which becomes '>' for the '.row > div > table' selector. OPW-2716089 closes odoo/odoo#81932 X-original-commit: 158c0ae425b3be446d81c3a6f4387b2d9426d10e Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: Claude Thibault (thcl) --- addons/web/models/base_document_layout.py | 3 ++- addons/web/views/report_templates.xml | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/web/models/base_document_layout.py b/addons/web/models/base_document_layout.py index 732c4a8beea..b73be78821e 100644 --- a/addons/web/models/base_document_layout.py +++ b/addons/web/models/base_document_layout.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import markupsafe from PIL import Image from markupsafe import Markup @@ -117,7 +118,7 @@ class BaseDocumentLayout(models.TransientModel): wizard_with_logo = wizard.with_context(bin_size=False) else: wizard_with_logo = wizard - preview_css = self._get_css_for_preview(styles, wizard_with_logo.id) + preview_css = markupsafe.Markup(self._get_css_for_preview(styles, wizard_with_logo.id)) ir_ui_view = wizard_with_logo.env['ir.ui.view'] wizard.preview = ir_ui_view._render_template('web.report_invoice_wizard_preview', {'company': wizard_with_logo, 'preview_css': preview_css}) else: diff --git a/addons/web/views/report_templates.xml b/addons/web/views/report_templates.xml index bb6c620c4cf..cd01fed3b8f 100644 --- a/addons/web/views/report_templates.xml +++ b/addons/web/views/report_templates.xml @@ -160,8 +160,8 @@ Description Quantity - Unit Price - Taxes + Unit Price + Taxes Amount @@ -174,10 +174,10 @@ 5.000 - + 1,500.00 - + 15.00% @@ -190,10 +190,10 @@ 5.000 - + 2,350.00 - + 15.00%