diff --git a/docx_report_generation/__manifest__.py b/docx_report_generation/__manifest__.py index 2f79f32..f3107f1 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.2.6", + "version": "16.0.2.2.7", "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 d580294..be427b6 100644 --- a/docx_report_generation/models/ir_actions_report.py +++ b/docx_report_generation/models/ir_actions_report.py @@ -530,6 +530,11 @@ class IrActionsReport(models.Model): jinja_env = jinja2.Environment() + def _localesel(record, field): + if not hasattr(record, '_fields'): + record = values['record'] + return record._fields[field].convert_to_export(getattr(record, field), self) + docx_content = BytesIO() with BytesIO(b64decode(template)) as template_file: doc = DocxTemplate(template_file) @@ -541,9 +546,7 @@ class IrActionsReport(models.Model): format_datetime(self.env, dt, dt_format=df) ) jinja_env.filters['duration'] = lambda du: format_duration(du) - jinja_env.filters['localesel'] = lambda record, field: ( - record._fields[field].convert_to_export(getattr(record, field), self) - ) + jinja_env.filters['localesel'] = _localesel doc.render(values, jinja_env) doc.save(docx_content) docx_content.seek(0)