[FIX] project: fix tags filtering based project for mobile view

Before this commit, when we click on the tag field in mobile view
it will display all the tags because in mobile view it will open
the kanban view on click of m2m field so 'search_read' called
instead of '_name_search'.

So in this commit, fixes the issue by applying the same filter
domain in search_read.

task-2790019

closes odoo/odoo#91670

X-original-commit: f23089f1fc14852fdd67916d38881746b15ebd19
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
Manisha Tulsiyani
2022-05-18 17:09:36 +02:00
committed by Barad Mahendra
parent 522548f4ad
commit 849c5e128b
+13 -5
View File
@@ -2402,15 +2402,23 @@ class ProjectTags(models.Model):
('name_uniq', 'unique (name)', "A tag with the same name already exists."),
]
def _get_project_tags_domain(self, domain, project_id):
return AND([
domain,
['|', ('task_ids.project_id', '=', project_id), ('project_ids', 'in', project_id)]
])
@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if 'project_id' in self.env.context:
domain = self._get_project_tags_domain(domain, self.env.context.get('project_id'))
return super().search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order)
@api.model
def _name_search(self, name='', args=None, operator='ilike', limit=100, name_get_uid=None):
domain = args
if 'project_id' in self.env.context:
project_id = self.env.context.get('project_id')
domain = AND([
domain,
['|', ('task_ids.project_id', '=', project_id), ('project_ids', 'in', project_id)]
])
domain = self._get_project_tags_domain(domain, self.env.context.get('project_id'))
return super()._name_search(name, domain, operator, limit, name_get_uid)
@api.model