Return a report from a button


I’m looking for a way to return a report from a button. I tried the following syntaxes:

def print_label(cls, moves):
    Label = Pool().get('product.label', type='report')
    oext, content, _, _ = Label.execute([ for x in moves], {})
    return ???

There, I don’t know which syntax to use to return the generated report to the client

def print_label(cls, moves):
    action_reports = Pool().get('').search([
            ('report_name', '=', 'product.label'),
    # How to set the IDs ???
    return action_reports

with this syntax I don’t know how to indicate the IDs on which the report should be generated ??

Thank you.

You should use button_action decorator, with the xml_id of report action, similar to this:

def button(cls, records):

There are samples on core modules:

Thanks, but this syntax launches a report with in ‘records’ a list of movements, whereas in ‘records’ I would need a list of products (because the report is a report linked to products).

Then you have to pass first by a wizard (button_action being a wizard) that setup the action with the proper ids.

The param “content” have the data from your report.
Save it to a file ex labels.odt and return to client

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.