[FIX]Docx Report Generation : needs tail to add not surrouneded data

This commit is contained in:
Fabien BOURGEOIS 2025-02-05 20:58:07 +01:00
parent cf23e0df8d
commit 71b7b19caa
2 changed files with 8 additions and 5 deletions

View File

@ -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"]},

View File

@ -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