[FIX] project: fix can't edit attachment with studio

Issue

    - Install Projects & Studio
    - Go into projects app
    - Edit a project (... => Edit)
    - Click on x attachments stat button

    You can't edit with studio

Cause

    Writing the action manually instead of using the base one
    result with an empty xml_id (and a lot of missing data).

Solution

    Use base.action_attachment like others modules do (e.g. helpdesk).

OPW-2146741

closes odoo/odoo#43263

X-original-commit: 856b09d7055ebbfebbe3b5dc3093e429c8c930ff
Signed-off-by: Jason Van Malder <jvm-odoo@users.noreply.github.com>
This commit is contained in:
Jason Van Malder
2020-01-14 10:37:36 +00:00
parent 1900abf233
commit c76c1dd30c
+12 -19
View File
@@ -96,26 +96,19 @@ class Project(models.Model):
project.task_count = result.get(project.id, 0)
def attachment_tree_view(self):
self.ensure_one()
domain = [
attachment_action = self.env.ref('base.action_attachment')
action = attachment_action.read()[0]
action['domain'] = str([
'|',
'&', ('res_model', '=', 'project.project'), ('res_id', 'in', self.ids),
'&', ('res_model', '=', 'project.task'), ('res_id', 'in', self.task_ids.ids)]
return {
'name': _('Attachments'),
'domain': domain,
'res_model': 'ir.attachment',
'type': 'ir.actions.act_window',
'view_id': False,
'view_mode': 'kanban,tree,form',
'help': _('''<p class="o_view_nocontent_smiling_face">
Documents are attached to the tasks of your project.</p><p>
Send messages or log internal notes with attachments to link
documents to your project.
</p>'''),
'limit': 80,
'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id)
}
'&',
('res_model', '=', 'project.project'),
('res_id', 'in', self.ids),
'&',
('res_model', '=', 'project.task'),
('res_id', 'in', self.task_ids.ids)
])
action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id)
return action
@api.model
def activate_sample_project(self):