Odoo Help


Call a report from a button

Milwell Sia
on 4/7/16, 6:24 AM 1,415 views

I'm using odoo8.  I have a Transient Model used in a Dialog Form.

The view has a button:

<button name="summary_report" type="object" string="Invoice Summary"/>

summary_report is defined in the transient model: mil.sales_report

def summary_report(self):
datas = {}
invoices = self.env['account.invoice'].search([
('company_id', '=', self.company_id.id)
context = dict({}, active_ids=invoices, active_model='account.invoice')
datas = {
return {
'type': 'ir.actions.report.xml',
'report_name': 'mil_sales_report.invoice_summary_template',
'context': context

I am trying to query the account.invoice model and pass the results to report 'mil_sales_report.invoice_summary_template'.
When I press the button widow closes and nothing happens.

Milwell Sia
On 4/8/16, 8:10 PM

It now works.  I changed the code to:

#needed for calling function from wizard, api.one will not work
#function definition is in odoo v8 format
def summary_report(self):
#ensure that self contains only one record
#get the model to query
invoiceModel = self.env['account.invoice']
#query the model
invoices = invoiceModel.search([
('company_id', '=', self.company_id.id)
#set the data
#ids is the list of ids, so have to pass <model>._ids
#model is the model name <model>._name or string literal
#form is the field list, I use <model>.read() to get all fields, read() can have parameter to only read specific fields
datas = {
'ids': invoices._ids,
'model': invoiceModel._name,
'form': invoiceModel.read(),
#call the report
return {
'type': 'ir.actions.report.xml',
'report_name': 'mil_sales_report.invoice_summary_template',
'datas': datas


Parikshit Vaghasiya

--Parikshit Vaghasiya--
| 6 3 8
--Parikshit Vaghasiya--

Working as an OpenERP/Odoo developer both experience in web and addons. you can contact me at:

E-mail : parikshitvaghasiya@gmail.com

Blog : parikshitvaghasiya.blogspot.in

Stackoverflow : http://stackoverflow.com/users/5089106/parikshit-vaghasiya

Parikshit Vaghasiya
On 4/7/16, 8:46 AM

def summary_report(self, cr, uid, ids, data, context=None):

if context is None:

context = {} #yourCode

return self.pool['report'].get_action(cr, uid, [], 'mil_sales_report.invoice_summary_template', data=datas, context=context)

 hope this will help you !

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

1 follower(s)


Asked: 4/7/16, 6:24 AM
Seen: 1415 times
Last updated: 4/8/16, 8:11 PM