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

Hello !

how can I set default value to my filter button in search view? I try to set a context to the action like the way it is in partner module but no result :

<field name="context">{'default_customer':0, 'search_default_supplier': 1, 'default_supplier':1}</field>
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can use only those fields which are defined in search view.

For this you need to pass proper key and value in context.key should like this

search_default_filter_name

Example: In res_partner search view there is one filter like this

<filter string="Persons" name="type_person" icon="terp-personal" domain="[('is_company','=',0)]"/>

If you want this filter as default pass context like this

<field name="context">{"search_default_customer":1,"search_default_type_person":1}</field>

If you don't want search_default_customer use {"search_default_type_person":1} instate of passing like this {"search_default_customer":0,"search_default_type_person":1}

You can also use field from search view

<field name="parent_id" filter_domain="[('parent_id','child_of',[self])]"/>

for use field pass context like this {"search_default_parent_id":1}

hope this will help

Ảnh đại diện
Huỷ bỏ

How can i Set default filter on company of logged-in user in search view for any object..? because user_id.company_id.id is not working for me.

this is a question related to default search views. Suppose i need to dynamically enable or disable a filter how could i do? I tried this but it's not working: {'search_default_not_closed':1, 'search_default_lancement':[('defaultLancement','=', True)]} Thanks

Câu trả lời hay nhất

How can i Set default filter on company of logged-in user in search view for any object..? because user_id.company_id.id is not working for me.

Ảnh đại diện
Huỷ bỏ

Hi, I have this issue too. How can i set default filter for Customers as per their logged in company ?!

You should have a look how multi company logic works. You should look at rules which are filters made before your actual search. See in security folder of various modules, look for model="ir.rule" with for example :

<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]

Câu trả lời hay nhất

As an addon, if you have created a new filter using studio, you will need to use the filter name (something like "studio_filter_xyz") which is attributed by Odoo automatically, and which is not the same as the string that is shown to the end user (something like "my filter". I mistakenly tried the latter, and after reading this post I understood it had to be th 'name'.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 3 15
7477
1
thg 3 15
6731
0
thg 3 15
3844
0
thg 3 15
3793
1
thg 3 15
5665