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

In Base model method are defined using decorator.

I have tried to override the base model with this solution but it coudln't work.

    from openerp.models import BaseModel

    class custom_class(BaseModel)

        @api.multi

        def method_name

 

@ I have tried with applyting decorator and without decorator but my override function is not called yet. Any suggestion will be appreciated.

아바타
취소

Why are you inheriting from BaseModel (i.e. class custom_class(BaseModel)). I did not found any use of BaseModel in this way in the addons, but maybe I'm missing something.

작성자

I want to apply some global changes on odoo8 so for that I want to override the core methods or the main method. do you have any idea?

Duplicate question maybe? https://www.odoo.com/forum/help-1/question/how-to-override-basemodel-or-model-class-of-orm-py-36517

베스트 답변

Hello Anil,

Try can try with following example in which I have assigned my own method to read of base method:

from openerp.models import BaseModel

from openerp import api

@api.v8

def my_read(self, fields=None, load='_classic_read'):

#your code goes here

BaseModel.read = my_read

I guess this is what you are looking for.

Hope this will help you.

아바타
취소
작성자

Thanks @Sudhir it works for me!

And how do you actually override, let's say, the create function ? Because if you return BaaseModel.create at the end of your custom create, you will have recursion issues.

You don't have to call no one. The return of the new method IS the return of the old method. The old one has been overwritten (i.e. replaced) altogether.

hello Sudhir.. it gives me this error TypeError: my_user_has_groups() takes at least 4 arguments (2 given). Can you check this qtn ... http://stackoverflow.com/questions/34725611/how-to-override-method-of-basemodel-openerp-models-py-in-odoo-v9