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

Hi, 

What I need

I want to create a flag in res.partner, and if this flag is true I don't want those records to be listed anywhere. The records should only be listed if  I choose a filter to show them.

What I achieved  

I've inherit the search function: 

flag= fields.Boolean(string='Do not list')
@api.model    
def search(self, args, offset=0, limit=None, order=None, count=False):
 """ Do not display the recods that have the field wv_do_not_list true""" 
    ctx = self.env.context
    if not ctx.get('search_wv_show_all', False): 
        args_old = expression.normalize_domain(args)
        args = expression.AND(
             (args_old, [('flag', '=', False)])
        )
    return super(Partner, self).search(args, offset=offset, limit=limit, order=order, count=count)

And created the filter: 

<filter string="All contacts" name="all_do_not_list" context="{'search_wv_show_all': True}"  help="All partners even the Do not list contacts"/>


In list view, kanban view this works, this prevents the records with the flag True to be listed.
But when I go to other model, all records with or without the flag are listed in the many2one fields linked to res.partner. 

What is missing ?

Thanks in advance  

아바타
취소
관련 게시물 답글 화면 활동
0
9월 21
4571
0
9월 17
2995
0
3월 15
3694
0
3월 15
4235
3
2월 25
35661