Skip to content

Commit

Permalink
[FIX] web: show page number in report
Browse files Browse the repository at this point in the history
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 odoo#30095
  • Loading branch information
nle-odoo committed Jan 11, 2019
1 parent be6f1aa commit adb52c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/web/views/report_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
7 changes: 7 additions & 0 deletions odoo/addons/base/models/ir_actions_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ def close_streams(streams):
def render_qweb_pdf(self, res_ids=None, data=None):
if not data:
data = {}
data.setdefault('report_type', 'pdf')

# remove editor feature in pdf generation
data.update(enable_editor=False)
Expand Down Expand Up @@ -700,13 +701,19 @@ def render_qweb_pdf(self, res_ids=None, data=None):

@api.model
def render_qweb_text(self, docids, data=None):
if not data:
data = {}
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.
"""
if not data:
data = {}
data.setdefault('report_type', 'html')
data = self._get_rendering_context(docids, data)
return self.render_template(self.report_name, data), 'html'

Expand Down

0 comments on commit adb52c5

Please sign in to comment.