Contributors mailing list archives


trying to create pdf from page created with website builder

redCOR AG, Robert Rottermann
- 09/11/2017 11:58:13

Hi there,

I would like to create print a page created with the website builder, but fail so far.

Maybe somebody can give me a hint how to do it:

my first atempt so far:

class pdf_report(http.Controller):
    @http.route('/page/pdf_report/<page>', auth='public')
    def pdf_report(self, **kw):
        request = http.request
        page = kw.get('page')
        # get the template stored by the website builder
        template = request._env.get('ir.ui.view').search([('name', '=', page)])
        # data is the qweb template
        # u'<t t-name="website.zeiterfassung">\n  <t t-call="website.layout">\n ...
        data = template.arch
        if data:
            return request.render(data)

however this produces a because the template tries to access the external id "website.zeiterfassung"

and fails.

"zeiterfassung" is in fact the name of the page.

any help would be appreciated.