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

Hello, I am trying to override a create method for the crm.leads model, but cant seem to get the overridden method to be called instead of the original.

Can someone tell me how to override another method from an inherited module?

아바타
취소
베스트 답변
  1. Have you imported your python module on __init__,py where your custom class are declared?
  2. Have you called your class after the class declaration?
  3. Have you imported the crm module on __openerp__.py file?

Example:

my_module.py file:

 class my_crm_lead(base_stage, format_address, osv.osv):
    _inherit='crm.lead'
    def create(self, cr, uid, vals, context=None):
         if context is None:
            context = {}
         create_context = dict(context)
         return super(crm_lead, self).create(cr, uid, vals, context=create_context)

my_crm_lead() #call the class it's required

__init__.py file:

import my_module

__openerp__.py file:

{
   'name': 'My CRM',
   'version': '1.0',
   'category': '...',
   'description':"...",
   'depends': ['crm'],
   'installable': True,
}
아바타
취소
작성자

Hello, and thanks for your help. I forgot to import the class file in the __init__.py file. Once I did that then it worked

Hello Eric. Please, could you mark my answer as the correct?

베스트 답변

You need to add the original module on openerp "Depends" List file. In that case i think is the crm.

Hope it helps.

아바타
취소
베스트 답변

What Rafael Reuber says it's true, but call the function (point number 2) it's not necessary.

Andrea

아바타
취소
관련 게시물 답글 화면 활동
2
2월 18
33380
0
4월 15
3613
0
10월 24
1198
3
7월 18
4087
0
2월 17
5