Reports are written in HTML/QWeb, like all regular views in Odoo. You can use the usualQWeb control flow tools. The PDF rendering itself is performed bywkhtmltopdf.

If you want to create a report on a certain model, you will need to define thisReportand theReport templateit will use. If you wish, you can also specify a specificPaper Formatfor this report. Finally, if you need access to more than your model, you can define aCustom Reportsclass that gives you access to more models and records in the template.

Report

Every report must be declared by areport action.

For simplicity, a shortcut<report>element is available to define a report, rather than have to set upthe actionand its surroundings manually. That<report>can take the following attributes:

id

the generated record's external id

name(mandatory)

only useful as a mnemonic/description of the report when looking for one in a list of some sort

model(mandatory)

the model your report will be about

report_type(mandatory)

either qweb-pdf for PDF reports or qweb-html for HTML

report_name

the name of your report (which will be the name of the PDF output)

groups

Many2many field to the groups allowed to view/use the current report

attachment_use if set to True, the report will be stored as an attachment of the record using the name generated by the

attachment expression; you can use this if you need your report to be generated only once (for legal reasons, for example)

attachment

python expression that defines the name of the report; the record is acessible as the variable object

paperformat

external id of the paperformat you wish to use (defaults to the company's paperformat if not specified)

Example:

<report
    id="account_invoices"
    model="account.invoice"
    string="Invoices"
    report_type="qweb-pdf"
    name="account.report_invoice"
    file="account.report_invoice"
    attachment_use="True"
    attachment="(object.state in ('open','paid')) and
        ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>

results matching ""

    No results matching ""