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

How to show fields values in _constraints messages?

I want to show in the error messages the values of the fields that trigger the constraint, how to do this?

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

Hi,

Refer the code of base_vat module to show the value of field in constraint message:

"_construct_constraint_msg" method to show the message
_constraints = [(check_vat, _construct_constraint_msg, ["vat"])]

Hope this may help you.

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

Hi.

I think like the error messages: use string and edit it before shown

if not rout_id:
  e_mess = "No rotuing there " + str(row) + "  column"
  raise osv.except_osv(_('Error in imported data'), _(e_mess))   

The row is varaible of course in this case. U can use any field value as you want..

Bye.

 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Sql constraint for boolean field แก้ไขแล้ว
2
ก.ย. 18
6869
9
มี.ค. 16
60768
1
มี.ค. 15
4718
1
มี.ค. 15
5469
0
พ.ย. 24
7