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

I want to create a customer_number in the format of cust<id> (For example, cust001, cust004,.. ) using the id. When I use the create() function it returns the id of the record. So I decided to update the record with my customer_number using the id of the record. The following code is in the create() function

@api.model

def create(self, vals):

    res = super(lot_number, self).create(vals)

     customer_id='cust'+str(res.id)

    vals.update({'customer_id':customer_id}) 

    res = super(lot_number, self).write(vals)

    return res




This code didn't show any error. and also the data not get updated.

i also ask this question in stack overflow.

https://stackoverflow.com/questions/53590435/how-to-override-update-function-of-a-custom-model-in-odoo-11

아바타
취소
베스트 답변

Hello Subash,

Try the following code

@api.model

def create(self, vals):

    res = super(lot_number, self).create(vals)

    res.customer_id = 'cust'+str(res.id)

    return res

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

Mr.Subbarao .... Thanks for your replay.. now it working fine. i struck with this for more than 4 hours. your reply helps me to save my time.

  Thanks alot. 

Subash Hariharan AR

아바타
취소
관련 게시물 답글 화면 활동
2
7월 24
2684
1
6월 24
5147
1
10월 23
10860
1
10월 23
98
1
8월 23
2193