From 71b7b19caa69f04b5ddf5e247a28bf99ca25e353 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Wed, 5 Feb 2025 20:58:07 +0100 Subject: [PATCH] [FIX]Docx Report Generation : needs tail to add not surrouneded data --- docx_report_generation/__manifest__.py | 2 +- docx_report_generation/models/ir_actions_report.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docx_report_generation/__manifest__.py b/docx_report_generation/__manifest__.py index 9e306de..1bcf8e6 100755 --- a/docx_report_generation/__manifest__.py +++ b/docx_report_generation/__manifest__.py @@ -14,7 +14,7 @@ "author": "RYDLAB, Yaltik", "website": "https://rydlab.ru", "category": "Technical", - "version": "16.0.2.1.1", + "version": "16.0.2.1.2", "license": "LGPL-3", "depends": ["base", "web", "custom_report_field", "report_monetary_helpers"], "external_dependencies": {"python": ["docxcompose", "docxtpl", "beautifulsoup4"]}, diff --git a/docx_report_generation/models/ir_actions_report.py b/docx_report_generation/models/ir_actions_report.py index cb7f8b7..8c68140 100644 --- a/docx_report_generation/models/ir_actions_report.py +++ b/docx_report_generation/models/ir_actions_report.py @@ -457,20 +457,21 @@ class IrActionsReport(models.Model): 'ol', 'li', 'font', 'a'): if child.tag == 'p': p = md.add_paragraph(child.text) + p.add_run(child.tail) elif child.tag == 'a': p.add_run(child.text).style = 'Hyperlink' elif child.tag == 'strong': p.add_run(child.text).bold = True - p.add_run(' ') + p.add_run(child.tail) elif child.tag == 'em': p.add_run(child.text).italic = True - p.add_run(' ') + p.add_run(child.tail) elif child.tag == 'u': p.add_run(child.text).underline = True - p.add_run(' ') + p.add_run(child.tail) elif child.tag == 's': p.add_run(child.text).font.strike = True - p.add_run(' ') + p.add_run(child.tail) elif child.tag == 'font' and 'style' in child.attrib: if 'color' in child.get('style'): rgb = [int(_v) @@ -479,6 +480,7 @@ class IrActionsReport(models.Model): p.add_run(child.text).font.color.rgb = RGBColor(*rgb) else: p.add_run(child.text) + p.add_run(child.tail) elif child.tag == 'ul': list_type = '9' # 9/25/28 : •, 8 : -, 19 : v elif child.tag == 'ol': @@ -490,6 +492,7 @@ class IrActionsReport(models.Model): continue else: # Not handled, add text only p.add_run(child.text) + p.add_run(child.tail) return md return field