[FIX] report: only set --viewport-size for some reports
viewport-size was add by2254a97(and changed by0ea94b4) to force wkhtmltopdf to use `col-md-*` bootstrap css classes. As this argument change the `window` size and not the screen size, this lead to smaller fonts and overflow issues in reports. Only change it for reports that need it. Closes #7882
This commit is contained in:
@@ -269,7 +269,8 @@ class Report(osv.Model):
|
||||
# Run wkhtmltopdf process
|
||||
return self._run_wkhtmltopdf(
|
||||
cr, uid, headerhtml, footerhtml, contenthtml, context.get('landscape'),
|
||||
paperformat, specific_paperformat_args, save_in_attachment
|
||||
paperformat, specific_paperformat_args, save_in_attachment,
|
||||
context.get('set_viewport_size')
|
||||
)
|
||||
|
||||
@api.v8
|
||||
@@ -361,7 +362,7 @@ class Report(osv.Model):
|
||||
def _check_wkhtmltopdf(self):
|
||||
return wkhtmltopdf_state
|
||||
|
||||
def _run_wkhtmltopdf(self, cr, uid, headers, footers, bodies, landscape, paperformat, spec_paperformat_args=None, save_in_attachment=None):
|
||||
def _run_wkhtmltopdf(self, cr, uid, headers, footers, bodies, landscape, paperformat, spec_paperformat_args=None, save_in_attachment=None, set_viewport_size=False):
|
||||
"""Execute wkhtmltopdf as a subprocess in order to convert html given in input into a pdf
|
||||
document.
|
||||
|
||||
@@ -375,7 +376,7 @@ class Report(osv.Model):
|
||||
:returns: Content of the pdf as a string
|
||||
"""
|
||||
command_args = []
|
||||
if wkhtmltopdf_state == "ok":
|
||||
if set_viewport_size:
|
||||
command_args.extend(['--viewport-size', landscape and '1024x1280' or '1280x1024'])
|
||||
|
||||
# Passing the cookie to wkhtmltopdf in order to resolve internal links.
|
||||
|
||||
@@ -52,7 +52,7 @@ class sale_quote(http.Controller):
|
||||
days = (datetime.datetime.strptime(order.validity_date, '%Y-%m-%d') - datetime.datetime.now()).days + 1
|
||||
if pdf:
|
||||
report_obj = request.registry['report']
|
||||
pdf = report_obj.get_pdf(request.cr, SUPERUSER_ID, [order_id], 'website_quote.report_quote', data=None, context=request.context)
|
||||
pdf = report_obj.get_pdf(request.cr, SUPERUSER_ID, [order_id], 'website_quote.report_quote', data=None, context=dict(request.context, set_viewport_size=True))
|
||||
pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
|
||||
return request.make_response(pdf, headers=pdfhttpheaders)
|
||||
user = request.registry['res.users'].browse(request.cr, SUPERUSER_ID, request.uid, context=request.context)
|
||||
|
||||
Reference in New Issue
Block a user