コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
5010 ビュー

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
3242
1
8月 24
2471
2
11月 24
3745
3
10月 23
15195
2
2月 23
2679