跳至内容
菜单
此问题已终结
4 回复
13509 查看

How do we revert the value of the parameter changed by @api.onchange. Or get the original value back.

I'm on odoo Version 9.

Ex: 

@api.onchange('carrier_id')

def on_carrier_changed(self):

    if something:

        # give some warning & do some logic

        # revert back carrier_id

Thanks!

形象
丢弃
编写者 最佳答案

Hi no i didn’t find an answer to that question, but my coworker suggested to change the way I do things to eliminate needing to go into onchange: Doing validation in other area, using domain filter to filter out values I don’t want…etc


Update:

old values are in self._origin. Self only contains new values. Even self.id = openerp.models.NewId

形象
丢弃
最佳答案

Check The Onchange Product if stock is not available it will display warning as well as data will store.

so in your case you can erase your field and raise a warning

形象
丢弃
最佳答案

I'm too new to this forum to post a commentary so please forgive me my 'answer'.

Have you found any solution? I am searching for about an hour now and I cannot find any way how to solve it!

Thank you!

形象
丢弃
编写者

old values are in self._origin. Self only contains new values. Even self.id = openerp.models.NewId

相关帖文 回复 查看 活动
4
5月 23
17817
0
12月 24
1216
1
10月 23
1997
2
10月 23
2200
2
8月 23
4224