Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4631 Widoki

Hello,

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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!

Autor

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!

Powiązane posty Odpowiedzi Widoki Czynność
1
paź 23
2305
10
maj 15
17732
1
wrz 20
4516
0
cze 19
2574
0
paź 24
1755