Permalink
Browse files

[FIX] web: show page number in report

Following 4a3fd02 on the portal when displaying an invoice we may get
a report_type variable (with value 'html' or 'pdf') on the portal.

This was used to not display the page number when checking the report,
but when the report is printed in the backend this report_type was unset
so the page number was mistakenly removed too.

With this changeset, the report alway know if he is pdf, html or text
and only print the page number if it is of type pdf.

opw-1924729
closes #30095
  • Loading branch information...
nle-odoo committed Jan 10, 2019
1 parent f69fde6 commit e3d304b720013f9d38238018951fabde5a843bc9
Showing with 4 additions and 1 deletion.
  1. +1 −1 addons/web/views/report_templates.xml
  2. +3 −0 odoo/addons/base/models/ir_actions_report.py
@@ -281,7 +281,7 @@
<h4 class="mt0 mb0 text-uppercase" t-field="company.report_header"/>
</div>
<div class="col-1">
<ul t-if="report_type != 'html'" class="list-inline pagenumber float-right text-center">
<ul t-if="report_type == 'pdf'" class="list-inline pagenumber float-right text-center">
<li class="list-inline-item"><strong><span class="page"/></strong></li>
</ul>
</div>
@@ -674,6 +674,7 @@ def render_qweb_pdf(self, res_ids=None, data=None):
# bypassed
raise UserError(_("Unable to find Wkhtmltopdf on this system. The PDF can not be created."))

data.setdefault('report_type', 'pdf')
html = self.with_context(context).render_qweb_html(res_ids, data=data)[0]

# Ensure the current document is utf-8 encoded.
@@ -700,13 +701,15 @@ def render_qweb_pdf(self, res_ids=None, data=None):

@api.model
def render_qweb_text(self, docids, data=None):
data.setdefault('report_type', 'text')
data = self._get_rendering_context(docids, data)
return self.render_template(self.report_name, data), 'text'

@api.model
def render_qweb_html(self, docids, data=None):
"""This method generates and returns html version of a report.
"""
data.setdefault('report_type', 'html')
data = self._get_rendering_context(docids, data)
return self.render_template(self.report_name, data), 'html'

0 comments on commit e3d304b

Please sign in to comment.