From 849c5e128bc17eb88e5f1dfc9f1b3e1450ede6ef Mon Sep 17 00:00:00 2001 From: Manisha Tulsiyani Date: Fri, 25 Mar 2022 12:46:11 +0000 Subject: [PATCH] [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) --- addons/project/models/project.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index f81e623c8ec..8d170ca994a 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -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