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