Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hello, I have Odoo8.
I have a computed field which definition of method is: def _actualiza_monto(self) so my only parameter is self. In this method I need to call other methods of this class which requires cr, uid and an integer value (in my case is self.id). The method definition is:
def mymethod(self, cr, uid, id_neccesary, context=None): ...
When I try to call the method with syntax self.mymethod(self.env.cr, self.env.uid, self.id, self.env.context) I get the error "5 parameters is needed, 8 given". Why? How it works? Thanks!
You are coding in a method which has API styling... hence your self will be a environment browse variable..
Hence when you are trying to call the method of same object, you need not to pass all the argument,,
just write it like this: self.mymethod()
calling of method is depends on the convention of the object declaration
Say user object and partner object:
parter_obj = self.pool.get('res.partner')
user_env = self.env['res.users']
partner_obj.calling_method(cr, uid, new_partner_id) [Old style since object is declared as Pool]
new_user_browse.calling_method() [API style since object is declared as Environment]
I have written both styling in API style method, hope you got the difference
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 1/8/15, 2:44 PM|
|Seen: 1477 times|
|Last updated: 3/16/15, 8:10 AM|