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

Hi,

I'm new to Odoo. I have module "crm.lead" and my module "record.clone". Now I want to create a record that has some fields I need of the recent record has just been created.

Example: When I click on button "Create" in CRM and fill info on form, after that it will create a record in CRM, I want to create a record the same as that record in my module (maybe has less fields than CRM). How can I do that ? (Sorry for my english.)

아바타
취소
베스트 답변

Ok, The solution is to override create method of odoo. The idea is to override create method and on the click of create button method update or create new record in "record.clone" model. Below is how you can override odoo create method:

class Campus(models.Model):
    _name='campus'    
    @api.model
    def create(self,values):
        campus_create = super(Campus,self).create(values)
        return campus_create

For more details

Reference: https://goo.gl/4BkizH

아바타
취소

For more details

Reference: https://goo.gl/4BkizH

베스트 답변

Hello Hserht,

you have to inherit crm model like this.

class CRM(models.Model):

    _inherit = 'crm.lead'    


    @api.model

    def create(self,values):

        result = super(CRM,self).create(values)

        clone_vals = {

                        what are all the fields you want pass here, you can get fields data from values

                        }

        self.env['record.clone'].create(clone_vals)

        return result


make sure record.clone model have create permission for logged in user

아바타
취소
작성자 베스트 답변

I can't comment in your answer because I dont have enough Karma, sorry about that.

Maybe you're not clear my problem (or my english is bad). The point is when I click button "Create" IN "crm.lead" NOT IN "record.clone".  CRM will create a record, and so does my module. (1 click create 2 record , one in CRM and one in mine).

아바타
취소
작성자

I found solution. Just creating some fields in module "record.clone" which is the same type as fields in "crm.lead", and create another models that _inherit models "crm.lead" (ex. "CRMLeadinherit"), then override create method in "crm.lead" and create the clone record in that method:

class CRMLeadinherit(models.Model):

_inherit='crm.lead'

@api.model

def create(self,values):

result = super(CRMLeadinherit,self).create(values)

vals = {'name': values.get('name'), ...}

return result

thanks Sehrish for your help !

작성자

'name' in vals is a fields that have the same type with values['name'] belongs to "record.clone" :))

welcome :)

관련 게시물 답글 화면 활동
2
8월 25
1468
0
5월 25
747
0
8월 24
1066
2
3월 24
1346
1
7월 22
2674