jack10bells
jack10bells

Reputation: 1

Odoo 8 - Qweb output PDF for HR Evaluation Report

when clicking the Print Survey button (Human Resources - Apraissal - Interview Requests), the standard output is HTML (action_print_survey method). I want to change output to PDF. I couldn't find on Odoo configuration nor standard structure for Qweb reports the way they do it as the standard stands (template yes, menu no, python wrapper no). I tried to right a wrapper but it doesn't work. Any ideas? Thanks in advance Gustavo

Upvotes: 0

Views: 829

Answers (2)

aekis.dev
aekis.dev

Reputation: 2764

@Gustavo That is not an html report, it's a rendered template in response to the request for print the survey using that button action. That's why you couldn't find any declaration for the report but you could easily do it by changing the method definition of the model survey.survey like:

def action_print_survey(self, cr, uid, ids, context=None):
    context = dict(context or {}, active_ids=ids, active_model=self._name)
    return {
        'type': 'ir.actions.report.xml',
        'report_name': 'module.survey_print',
        'context': context,
    }

Also you need to define the report module.survey_print to use the original template. For that you could see how to do it on: https://www.odoo.com/fr_FR/forum/help-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244

Upvotes: 0

Jainik Patel
Jainik Patel

Reputation: 2324

Report

Every report must be declared by a report action.

For simplicity, a shortcut <report> element is available to define a report, rather than have to set up the action and 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

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')"
/>

Reference Link : https://www.odoo.com/documentation/8.0/reference/reports.html

Upvotes: 0

Related Questions