Odoo Help


How can I pass customs ids to 'datas'

on 7/3/13, 4:49 PM 1,794 views


I am very new with OpenERP and I been trying to make a report to work. Finally I discover that context.get('active_ids', []) was returning nothing and thats part of the reason my report was not working.

Is there anyway I can pass "custom" ids to datas. Lets say I know the ID in the database and its 22 how can I give it to datas to test if it works?

I tried appending 22 but I keep getting an error like the following:

except_osv: (u'<LongTable@0x7F191831AAB8 0 rows x unknown cols>... must have at least a row and column

My code looks like the following

def print_report(self,cr,uid,ids,context):
    if context is None:
        context = {}

    datas = {'ids': context.get('active_ids', [])}
    datas['model'] = 'sim.prov'
    res = self.read(cr, uid, ids, context=context)
    res = res and res[0] or {}
    datas['form'] = res
    return {
        'type': 'ir.actions.report.xml',
        'report_name': 'sim.prov',
        'datas': datas,

Any tip much appreciated




| 5 5 8
Bogotá, Colombia
Informatics engineer Industrial engineer
On 7/3/13, 5:03 PM

In your example datas is a dictionary {}, 'ids' inside datas is a list [], if you want to append ids to the ids list do this:

datas = {'ids': context.get('active_ids', [])+[22,21]}

I would not recommend to use constant id numbers in the code, you could use the search function or other alternatives, but that is your decision.

Thanks, yes this is just for testing proposes. Unfortunately when I add you code I still get the "must have at least a row and column" error. I checked 1000 times if the table with that name (sim.prov) has records and it does. I am not sure what I am doing wrong. Anyway thanks for the help!

on 7/3/13, 5:13 PM

OH I found the error was referring to the RML file and not to the .py file...its odd but as soon as I added a table to the RML file everything is working! Thanks for the inspiration!

on 7/3/13, 5:20 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

0 follower(s)


Asked: 7/3/13, 4:49 PM
Seen: 1794 times
Last updated: 3/16/15, 8:10 AM