تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
4137 أدوات العرض


@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?

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
@api.constrains تم الحل
2
ديسمبر 23
2509
0
يونيو 21
2301
2
يونيو 20
2848
2
مارس 24
5116
1
يوليو 23
1290