[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
This commit is contained in:
Vincent Larcin
2022-06-03 16:40:49 +02:00
parent 0452d0701f
commit 26cbec91cd
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -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)))]
@@ -96,7 +96,7 @@
</div>
</div>
</div>
<h2>Analytics</h2>
<h2 name="section_analytics">Analytics</h2>
<div class="row mt16 o_settings_container" name="analytic">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">