1

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 Answers1

0

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

Kenly
  • 24,317
  • 7
  • 44
  • 60
  • Thanks for the quick reply and links to the documentation. I'm still quite new to Odoo, but just to be clear since automated actions ignore the returned value there is no way to trigger a report action from an automated action created with the Odoo Studio UI? – Brendan Cariota Aug 25 '22 at 20:31
  • 1
    Unfortunately you can't use `action`. – Kenly Aug 25 '22 at 21:36