Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
13833 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
4
พ.ค. 23
18217
0
ธ.ค. 24
1524
1
ต.ค. 23
2284
"Wrong value for %s: %r" % (self, value) แก้ไขแล้ว
2
ต.ค. 23
2491
2
ส.ค. 23
4601