콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4628 화면

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()

Note:

calling of method is depends on the convention of the object declaration

Say user object and partner object:

def sample_method(self):
    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

아바타
취소
베스트 답변

AFAIK, computed field would receive at least cr, uid, ids, field_name, and arg.  You may need to update the _actualiza_monto method to follow the signature.  Which is def _actualiza_monto(self, cr, uid, ids, field_name, arg, context=None).

아바타
취소
관련 게시물 답글 화면 활동
2
12월 22
14929
1
11월 21
5053
0
1월 21
2351
8
5월 20
7936
0
12월 23
2988