[IMP]DOCX Report Generation : new jinja filter localesel
This commit is contained in:
parent
71b7b19caa
commit
1c5a0cf374
@ -14,7 +14,7 @@
|
||||
"author": "RYDLAB, Yaltik",
|
||||
"website": "https://rydlab.ru",
|
||||
"category": "Technical",
|
||||
"version": "16.0.2.1.2",
|
||||
"version": "16.0.2.1.3",
|
||||
"license": "LGPL-3",
|
||||
"depends": ["base", "web", "custom_report_field", "report_monetary_helpers"],
|
||||
"external_dependencies": {"python": ["docxcompose", "docxtpl", "beautifulsoup4"]},
|
||||
|
@ -503,6 +503,9 @@ class IrActionsReport(models.Model):
|
||||
doc = DocxTemplate(template_file)
|
||||
jinja_env.filters['htmlgen'] = partial(_html_generate, tpl=doc)
|
||||
jinja_env.filters['datefmt'] = lambda dt: format_date(self.env, dt)
|
||||
jinja_env.filters['localesel'] = lambda record, field: (
|
||||
record._fields[field].convert_to_export(getattr(record, field), self)
|
||||
)
|
||||
doc.render(values, jinja_env)
|
||||
doc.save(docx_content)
|
||||
docx_content.seek(0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user