Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
4733 Tampilan

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

Avatar
Buang
Penulis

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 ?

Jawaban Terbai

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()


Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
4
Feb 25
2457
1
Agu 24
2051
2
Nov 24
3218
3
Okt 23
14747
2
Feb 23
2428