From f384db9b6752f5251f5f3ecee1d0020e29e8b2aa Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Thu, 5 Apr 2018 16:55:06 +0200 Subject: [PATCH] [IMP] base, web: define landscape in report template Since report refactoring the function to override is get_report_values that only returns a dict of value that are used in rendering. In order to render a pdf with a landscape orientation, a context key could be added however since it's not possible to return a report object in get_report_values, it's difficult to add a contexti without using some tricks. This commit add a report option to use in the template that will be used in order to modify the pdf orientation. The process used was already existing for other options like dpi,... --- addons/web/views/report_templates.xml | 1 + odoo/addons/base/models/ir_actions_report.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/addons/web/views/report_templates.xml b/addons/web/views/report_templates.xml index 6c8b8b1ab06..e22bc9edaf2 100644 --- a/addons/web/views/report_templates.xml +++ b/addons/web/views/report_templates.xml @@ -50,6 +50,7 @@ t-att-data-report-margin-top="data_report_margin_top" t-att-data-report-header-spacing="data_report_header_spacing" t-att-data-report-dpi="data_report_dpi" + t-att-data-report-landscape="data_report_landscape" t-att-web-base-url="web_base_url"> diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py index f5537b631d2..f1d7c812fde 100644 --- a/odoo/addons/base/models/ir_actions_report.py +++ b/odoo/addons/base/models/ir_actions_report.py @@ -206,6 +206,9 @@ class IrActionsReport(models.Model): :param set_viewport_size: Enable a viewport sized '1024x1280' or '1280x1024' depending of landscape arg. :return: A list of string representing the wkhtmltopdf process command args. ''' + if landscape is None and specific_paperformat_args and specific_paperformat_args.get('data-report-landscape'): + landscape = specific_paperformat_args.get('data-report-landscape') + command_args = [] if set_viewport_size: command_args.extend(['--viewport-size', landscape and '1024x1280' or '1280x1024'])