Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
4802 Prikazi

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
Opusti
Avtor

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 ?

Best Answer

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
Opusti
Related Posts Odgovori Prikazi Aktivnost
4
feb. 25
2754
1
avg. 24
2252
2
nov. 24
3406
3
okt. 23
14933
2
feb. 23
2526