This question has been flagged
2910 Views

hi,

i have a problem understanding how to call methods on objects in openERP:

example: something(self,cr,uid,ids,context=None)

sometimes the method is called with only one parameter, sometimes with all the parameters, sometimes a few, sometimes you can omit the 'self' parameter, aargghh...

The exceptions i get (when calling a method wrongly) are also very confusing (in terms of nr of parameters)

Practically i always have to 'brute force/guess' every possibility before i can make a call, i just don't understand the logic. All my time is wasted on this stupid 'guessing-work'

Calling the function according to the prototype just does't seem to work in 90% of the cases.

It's so confusing, i'm very used to C++/Java and this method calling is really giving me a headache, 90% of my time is spent on how to figure out the correct way to call it. The prototypes of the methods just don't make any sense on how to call them.

Can someone please explain what i need to read/learn so i understand how to call member functions in openErp without always guessing the parameters (type,nr,..)?

thank you very much if you can help me

Avatar
Discard
Author

for example: i need to call a method

def make_initial_invoice(self, cr, uid, ids, context={}):

i calll it like this:

agreement.make_initial_invoice(cr,uid,[1])

and raises this exception: takes at most 5 arguments (7 given)

why does it say 7 parameters? I only give three, right??

even when i do this agreement.make_initial_invoice(cr,uid,1)

it's not working

What am i missing here? Basic Python? Or is it normal to 'guess' how to call every method?

You have to read all the openERP guide. The truth is that I learned debugging over all the openERP code. I work with Linux Mint, eclipse and that's all. When I don't know what's happening I only have to put a breakpoint there. At first it's a little bit weird but when you understand the logic it's quite easy.

Author

Thanks for your reply, my mistake was confusing a 'model' with a 'row'. I'm also using Ubuntu+eclipse with debugging, i've read the guide, but IMO, it's the naming of the classes/members particularly which is so confusing. I prefer calling a model of a cat, 'cat_model' and a record 'cat_record'. Names like cat_cat, mixed with cat are way too confusing. IMHO. :)