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


@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
3339
0
มิ.ย. 21
2663
2
มิ.ย. 20
3217
_sql_constraints fail to be effective แก้ไขแล้ว
2
มี.ค. 24
5685
1
ก.ค. 23
1695