Would it be possible to filter the data in res.partner directly in the inherited model before showing it on the page in a list view or kanban or any view?
I was thinking maybe by inheriting the search or read method. If it can be done, should it be done in one of these two or any other? can you please provide a guide on how to do it?
What I've tried, in the search method, I've tried to append my domain:
@api.model
def search(self, args, offset=0, limit=None, order=None):
args += [('id', '=', 8)]
print(args)
return super(ResPartner, self).search(args, offset, limit, order)
this will print two things:
[('id', 'in', [2, 7, 8, 9, 10, 11]), ('id', '=', 8)]
and
[('parent_id', 'in', [8, 9, 3, 1, 7, 10, 11]), ('id', '=', 8)]
which is not good, since it will still retrieve the full list.
Another thing that I've tried, is to reassign only my domain to the args:
@api.model
def search(self, args, offset=0, limit=None, order=None):
args = [('id', '=', 8)]
print(args)
return super(ResPartner, self).search(args, offset, limit, order)
this will print:
[('id', '=', 8)]
even though the args is now only my domain, it's still returning the full list that I want to filter and I can see everything in the page.
Is this the right direction to achieve this?
Any ideas are welcome!
Thanks