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


@onchange has self._origin to get previous values, but this is not available for @constrains.

How do you get the previous value of a field? This is most usefull sometimes when you want to add a constrain based on a previous value


Right now I'm solving this in the write() method by getting the value before and after calling super.write and then raising an UserError. Seems this would be better fit for constrains


Thanks



Аватар
Відмінити
Найкраща відповідь

I go further and asks how to know if it is a newly created record from inside constrains decorator method?

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
@api.constrains Вирішено
2
груд. 23
3317
0
черв. 21
2657
2
черв. 20
3212
2
бер. 24
5674
1
лип. 23
1693