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

Hello,


I want to create filter in odoo 11 but i don't want users to remove the filter from the search bar,

i want static filter to show request created only by a user instead of showing request created by all users.

Please see my code below but users is able to remove the filter and see others request.

 <filter icon = "terp-mail-message-new" string = "My Requests" name = "my_requests_filter" domain ="[('current_user', '=', uid)]"/>

<field name="context">{'search_default_my_requests_filter': 1}</field>


Any Help?

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

Hi, 
1- Add special context to your action
2- override _search function
3- Check if self._context.get('Your_context_here', False)
4- if exists, then add domain to args
5- When you open the view list trigged by the action, you will only see the records that verify your domain. No need to add a filter.

Hope this helps.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 6 20
2614
1
thg 6 21
3733
1
thg 3 21
3389
0
thg 1 21
2109
0
thg 6 20
2981