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

i am trying to add multiple conditions in domain filter, second filter is to check length of complete_name field which should be greater than 4.

field name="x_block" domain=" ['&' ('complete_name', 'ilike', 'Block'), (len(complete_name), '&gt', 4)]"

when compiling it is throwing error, please advise.

i am doing this through bug icon not using custom module.

regards



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

Hi,

The issue with your domain filter seems to be related to the use of Python functions within the domain filter. The Odoo framework doesn't allow the direct use of Python functions like len() within the domain filter. Instead, you need to use the appropriate syntax . Here you can store the length of the value in to another field and you can call that new field instead of using len()please go through the documentation below to know about the domain:
https://www.cybrosys.com/odoo/odoo-books/odoo-16-development/views/context-domain/


Hope it helps

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

Inside domain list first element of the tuple is suppose to be a string and a valid field name.

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

The first parameter should be a field. len(complete_name) is not acceptable. You have to create another field for length of complete_name field.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 23
1394
1
thg 1 24
1637
1
thg 5 25
2412
1
thg 4 25
3429
1
thg 4 25
4247