Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4502 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 18
6953
9
thg 3 16
60801
1
thg 3 15
4740
1
thg 3 15
5491
0
thg 11 24
7