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

I would like to determine whether the constraint has been triggered due to a user-initiated change from the Odoo UI or if it has been triggered from within the internal code of another application.


The code would be something like that:


class StockMove(models.Model):
_inherit = "stock.move"

​@api.constrains('sequence')
​def _constrains_sequence(self):
​​if comes_from_UI:
​raise ValidationError(_("Not allowed to change the sequence of moves from the picking."))

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hey, 


Maybe you can write onchange it will fit your needs.

Thanks

อวตาร
ละทิ้ง
ผู้เขียน

Hi Jay,

Thank you for your response. However, from my understanding, the onchange methods are executed not only when modifying values from the UI but also when modifying them from the code.

So, I would encounter the same issue while attempting to differentiate whether that change originates from a UI modification.

Related Posts ตอบกลับ มุมมอง กิจกรรม
5
พ.ค. 25
45994
1
ก.ค. 25
2358
2
ก.ค. 25
7853
2
ก.ค. 25
4251
2
ก.ค. 25
4014