Odoo Help


How to call report from button (Odoo)

Adnier Rosello
on 10/14/15, 9:17 PM 3,709 views

How I can call a report from a button (type = 'object') or (type = 'action'), for example, I have created a report of type:

<report id="action_products_consume_report"





     name="mrp.products_consume_document" />

and I need to call the same report from a button inside a tree view,



Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/14/15, 11:09 PM

Just define it like:

<button name="open_report_consume" type="object" string="Report Consume"/>
    def open_report_consume(self, cr, uid, ids, context=None):
        if ids:
if not isinstance(ids, list):
ids = [ids]
context = dict(context or {}, active_ids=ids, active_model=self._name)
return {
'type': 'ir.actions.report.xml',
'report_name': 'mrp.products_consume_document',
'context': context,

You need to change the report model to match the model 'mrp.production.products' of the field 'products_ids', because that model is where the button is defined. Change it like:

<report id="action_products_consume_report" string="Products" model="mrp.production.products" report_type="qweb-pdf" file="mrp.products_consume_document" name="mrp.products_consume_document" />

Also you need to use the fields at the report template from 'mrp.production.products' if you don't have it like that

Well, I've tried this and it works when the button is in the form view that belong to mrp.production model, but in my case I have the button within a field one2many that belong to same model, when I call the report I got this error: MissingError
One of the documents you are trying to access has been deleted, please try again after refreshing.
,MissingError ... exactly what I need it is to show a report (pdf) with the information(code, weight, etc..) from the record at the one2many field (products_ids), below the code that I used. ... ... Thanks

Adnier Rosello
on 10/15/15, 11:21 AM

I update the solution to include active_ids in the context. now show work for you in all the scenarios

Axel Mendoza
on 10/15/15, 11:36 AM

just what I needed, it's working for me, Thanks!!!

Adnier Rosello
on 10/15/15, 3:07 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 10/14/15, 9:17 PM
Seen: 3709 times
Last updated: 10/15/15, 3:07 PM