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

When I try to override my res.partner write method it executes multiple time 

How can I make sure it just does once or that I can only increment my field after it runs 

 @api.multi

    def write(self, vals):

        next_custnum = self.getnextcustno()

        vals['cust_no'] = next_custnum

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

        print("Execute Write")

        print("Execute Write after")

        self.addNextCustNo()

        return res

아바타
취소
작성자

Write and create both executes 2x on inheritance of red.partner ? How come ? Want to add changed items to a custom model but insert twice .. please help ?

베스트 답변

This is normal that write method calling multiple times.

You should add a condition in your code so that it does not execute each time.

Try the following code:

if not vals.get('cust_no'):
vals['cust_no'] = self.getnextcustno()


아바타
취소
관련 게시물 답글 화면 활동
4
2월 25
3367
1
8월 24
2533
2
11월 24
3815
3
10월 23
15285
2
2월 23
2759