콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
6095 화면

Whenever a user is trying to search sale order, quotation, lead, contract or invoice (in the top right corner), as the typing goes on the suggestions are shown for both customers and contacts within this company. In our installation we are looking for limiting that search to show only companies, which have is_company set to true. Any idea how to approach that?

아바타
취소

Please tell us, whether you'd like to use code, or the web interface to solve your issue.

작성자

Wouldn't it be easier to do that via web interface?

베스트 답변

Make sure you are logged in as a user with administration rights and technical features activated.

Go to: Settings -> Technical -> User Interface -> Views

Search for the view with view type 'Search' and for the object you want to change the search behaviour (in your case that might be sale.order or quotation, etc)

Duplicate the view and edit it:

  • Change the View Name (to whatever you like)
  • Set Inherited View to the exact view you just duplicated
  • Edit the Architecture as follows:

    1. Add a xpath tag arround the outer <search> tag with expr="/search" and position="replace".
    2. Add a domain attribute inside the field tag for those fields you want to change the behaviour.

Example for Partner Search View:

<?xml version="1.0"?> 
    <xpath expr="/search" position="replace"> 
        <search string="Search Partner"> 
            <field name="name" string="Name" domain="[('is_company','=',True),]" filter_domain="['|','|',('name','ilike',self),('parent_id','ilike',self),('ref','=',self)]"/>
                ... other fields and filters ...
        </search> 
    </xpath>
  • Save the new View and try it.

You might find the documentation helpful.

Regards.

아바타
취소
베스트 답변

In Default Sale order search view the below code used:-

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

Based on your requirement inherit search view and add the domain:-

            <field name="partner_id" domain="[('is_company','=',True)]"  filter_domain="[('partner_id', 'child_of', self)]"/>
아바타
취소
작성자

That works just fine, thanks a lot. Tried with domain before and couldn't make it happen to work. Marked as solved.

Upvoted, since you were faster than me.

Besides: Would it be a difference if ('is_company','=',True) is added to the filter_domain using logical AND?

관련 게시물 답글 화면 활동
2
11월 23
3317
1
12월 22
3111
0
12월 22
2957
1
12월 22
3290
1
2월 22
8923