[IMP] website_project: Show more attachments on my/task/

Show the attachements that don't come from the mail_messages on the my/task/ page (Like in old website_project_issue module)
This commit is contained in:
Yannick Tivisse
2017-08-07 12:17:10 +02:00
parent 095b0adc2e
commit e0d888fb3c
2 changed files with 23 additions and 0 deletions
+9
View File
@@ -47,6 +47,15 @@ class Task(models.Model):
website_url = fields.Char('Website URL', compute='_compute_website_url', help='The full URL to access the document through the website.')
attachment_ids = fields.One2many('ir.attachment', compute='_compute_attachment_ids', string="Main Attachments",
help="Attachment that don't come from message.")
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
message_attachment_ids = self.mapped('message_ids.attachment_ids').ids # from mail_thread
task.attachment_ids = list(set(attachment_ids) - set(message_attachment_ids))
def _compute_website_url(self):
for task in self:
task.website_url = '/my/task/%s' % task.id
@@ -195,6 +195,20 @@
<address t-field="task.user_id" t-field-options='{"widget": "contact", "fields": ["name", "email", "phone"]}'/>
</div>
</div>
<div t-if="task.attachment_ids" class='panel-footer'>
<strong>
<t t-if='len(task.attachment_ids)&gt;1'>Attachments</t>
<t t-else="">Attachment</t>
</strong>
<div class='row'>
<div class="col-md-2 col-sm-3 text-center oe_attachments" t-foreach='task.attachment_ids' t-as='attachment'>
<a t-attf-href="/web/content/#{attachment.id}?download=true" target="_blank">
<div class='oe_attachment_embedded o_image o_image_small' t-att-title="attachment.name" t-att-data-mimetype="attachment.mimetype" t-attf-data-src="/web/image/#{attachment.id}/50x40"/>
<div class='oe_attachment_name'><t t-esc='attachment.name' /></div>
</a>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="mb8" t-if="task.date_deadline">