[IMP]Docx Report Generation : new jinja filter datetimefmt

This commit is contained in:
Fabien BOURGEOIS 2025-02-21 08:43:16 +01:00
parent 7aab40164a
commit 0df7af86e1
2 changed files with 5 additions and 2 deletions

View File

@ -14,7 +14,7 @@
"author": "RYDLAB, Yaltik", "author": "RYDLAB, Yaltik",
"website": "https://rydlab.ru", "website": "https://rydlab.ru",
"category": "Technical", "category": "Technical",
"version": "16.0.2.2.4", "version": "16.0.2.2.5",
"license": "LGPL-3", "license": "LGPL-3",
"depends": ["base", "web", "custom_report_field", "report_monetary_helpers"], "depends": ["base", "web", "custom_report_field", "report_monetary_helpers"],
"external_dependencies": {"python": ["docxcompose", "docxtpl", "beautifulsoup4"]}, "external_dependencies": {"python": ["docxcompose", "docxtpl", "beautifulsoup4"]},

View File

@ -25,7 +25,7 @@ from odoo import _, api, fields, models
from odoo.exceptions import AccessError, UserError from odoo.exceptions import AccessError, UserError
from odoo.http import request from odoo.http import request
from odoo.tools.safe_eval import safe_eval, time from odoo.tools.safe_eval import safe_eval, time
from odoo.tools.misc import format_date from odoo.tools.misc import format_date, format_datetime
try: try:
from odoo.addons.gotenberg.service.utils import ( from odoo.addons.gotenberg.service.utils import (
@ -537,6 +537,9 @@ class IrActionsReport(models.Model):
jinja_env.filters['datefmt'] = lambda dt, df=False: ( jinja_env.filters['datefmt'] = lambda dt, df=False: (
format_date(self.env, dt, date_format=df) format_date(self.env, dt, date_format=df)
) )
jinja_env.filters['datetimefmt'] = lambda dt, df=False: (
format_datetime(self.env, dt, dt_format=df)
)
jinja_env.filters['localesel'] = lambda record, field: ( jinja_env.filters['localesel'] = lambda record, field: (
record._fields[field].convert_to_export(getattr(record, field), self) record._fields[field].convert_to_export(getattr(record, field), self)
) )