Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
5021 Переглядів

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


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
4
лют. 25
3263
1
серп. 24
2480
2
лист. 24
3761
3
жовт. 23
15204
2
лют. 23
2692