跳至內容
選單
此問題已被標幟
1 回覆
1715 瀏覽次數

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.

相關帖文 回覆 瀏覽次數 活動
5
5月 25
45774
1
7月 25
2237
2
7月 25
7721
2
7月 25
4140
2
7月 25
3897