How it works...

In step 1, we defined the structure of the report using the QWeb template language. Instead of using the record syntax as we did earlier, we used the template element here. This is entirely for convenience; QWeb reports are just views like all the others. The reason for using this element is that the arch field of QWeb views has to follow quite strict rules, and the template element generates an arch content that fulfills these rules.

Don't worry about the syntax within the template element now. This topic will be addressed extensively in the QWeb recipe in Chapter 16, Web Client Development.

In step 2, we declared the report in another XML file. The report element is another shortcut for an action of the ir.actions.report.xml type. The crucial part here is that you set the name field to the complete XML ID (that is, modulename.record_id) of the template you defined, or the report generation will fail. The model attribute determines which type of record the report operates, and the string attribute is the name shown to the user in the print menu.

By setting report_type to qweb-pdf, we requested that the HTML generated by our view is run through wkhtmltopdf in order to deliver a PDF to the user. In some cases, you may want to use qweb-html to render the HTML within the browser.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset