Browse Source

[FIX] emc_website_portal: PDF download issue

The bug was that trying to download the cooperator certificate or
another PDF in the interface brings an error 500. This was due to a
wrong usage of the function `get_pdf()` and also due to a error of
encoding when using `format()` python function with `{name}`. Instead I
use `"%s" % name` that works great.

It didn't use `get_pdf()` right because of an old version of mis-builder
that cause the methord `get_pdf()` to work weird. With an updated
version of mis-builder, `get_pdf()` can be used correctly.
pull/1/head
Rémy Taymans 6 years ago
parent
commit
00459d70fa
  1. 1
      easy_my_coop_website_portal/__openerp__.py
  2. 12
      easy_my_coop_website_portal/controllers/main.py

1
easy_my_coop_website_portal/__openerp__.py

@ -23,6 +23,7 @@
'website',
'website_portal_v10',
'easy_my_coop',
'report',
],
'data': [

12
easy_my_coop_website_portal/controllers/main.py

@ -125,12 +125,10 @@ class CooperatorWebsiteAccount(WebsiteAccount):
# Get the pdf
report_mgr = request.env['report'].sudo()
pdf = report_mgr.get_pdf(
capital_request.ids,
capital_request,
'easy_my_coop.theme_invoice_G002'
)
filename = "Release Capital Request - {oid}".format(
oid=capital_request.id
)
filename = "Release Capital Request - %d" % capital_request.id
return self._render_pdf(pdf, filename)
@http.route(['/my/cooperator_certificate/pdf'],
@ -140,12 +138,10 @@ class CooperatorWebsiteAccount(WebsiteAccount):
partner = request.env.user.partner_id
report_mgr = request.env['report'].sudo()
pdf = report_mgr.get_pdf(
partner.ids,
partner,
'easy_my_coop.cooperator_certificat_G001'
)
filename = "Cooperator Certificate - {name}".format(
name=partner.name
)
filename = "Cooperator Certificate - %s" % partner.name
return self._render_pdf(pdf, filename)
def _render_pdf(self, pdf, filename):

Loading…
Cancel
Save