From 26cbec91cd85aedb3cf7a7e2f81e047e88977da7 Mon Sep 17 00:00:00 2001 From: Vincent Larcin Date: Tue, 17 May 2022 13:39:16 +0000 Subject: [PATCH] [IMP] project: rework documents management This commit gives a name to the Analytics section in the settings to allow us to change its name easily with an xpath. It also extracts the attachments domain in tasks so that it can be overriden in documents_project to exclude attachements linked to a document. Related: https://github.com/odoo/enterprise/pull/26696 Related: https://github.com/odoo/upgrade/pull/3557 Task-2802803 Part-of: odoo/odoo#92044 --- addons/project/models/project.py | 6 +++++- addons/project/views/res_config_settings_views.xml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 6b4478af4f3..a37fe9528e5 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1499,9 +1499,13 @@ class Task(models.Model): if not self._check_recursion(): raise ValidationError(_('Error! You cannot create a recursive hierarchy of tasks.')) + def _get_attachments_search_domain(self): + self.ensure_one() + return [('res_id', '=', self.id), ('res_model', '=', 'project.task')] + def _compute_attachment_ids(self): for task in self: - attachment_ids = self.env['ir.attachment'].search([('res_id', '=', task.id), ('res_model', '=', 'project.task')]).ids + attachment_ids = self.env['ir.attachment'].search(task._get_attachments_search_domain()).ids message_attachment_ids = task.mapped('message_ids.attachment_ids').ids # from mail_thread task.attachment_ids = [(6, 0, list(set(attachment_ids) - set(message_attachment_ids)))] diff --git a/addons/project/views/res_config_settings_views.xml b/addons/project/views/res_config_settings_views.xml index 0bdd6a5d89f..02c842d86df 100644 --- a/addons/project/views/res_config_settings_views.xml +++ b/addons/project/views/res_config_settings_views.xml @@ -96,7 +96,7 @@ -

Analytics

+

Analytics