Odoo 15.0 - assign: action = {...} not working

Viewed 65

I am trying to automatically print a report when a field is triggered with an automated action. In the documentation is says to return an action assign: action = {...} but nothing is happening. Here is my code. I'm just trying to download the basic package report pdf so I can then print the pdf.

action = {
    'type': 'ir.actions.report',
    'name': 'Package Barcode (PDF)',
    'model': 'stock.quant.package',
    'report_type': 'qweb-pdf',
    'report_name': 'stock.action_report_quant_package_barcode_small',
   }

I have also tried to use the report_action() method to download and then print the pdf report but I have had no luck with that either.

env.ref('stock.action_report_quant_package_barcode_small').report_action(record)

Any help would be appreciated. I don't want to rely on a third party module. I'm just looking for the same functionality if you where to click on the print button and then select the report you wanted to print from the UI. It downloads the pdf then you can open it and print it from there.

1 Answers

The automated action will run the corresponding server action and ignore the returned value. It will not execute the returned action.

You see that in the documentation because the delegate parameter is set to True on the server action field which make fields of the target model (Server Action) accessible from the current model (corresponds to _inherits).

The automated action inherited the server action fields

Related