[FIX] mail: activities of archived records

- Create an activity for a crm lead
- Set the lead as lost

The activity still appears in the list.

A proper fix would be to have an `active` field on `mail.activity`. In
the meantime, simply delete activites when archiving.

opw-1817703
This commit is contained in:
Nicolas Martinelli
2018-03-05 11:49:42 +01:00
committed by Nicolas Martinelli
parent b53c017052
commit f7307d64b8
+9
View File
@@ -317,6 +317,15 @@ class MailActivityMixin(models.AbstractModel):
def _search_activity_summary(self, operator, operand):
return [('activity_ids.summary', operator, operand)]
@api.multi
def write(self, vals):
# Delete activities of archived record.
if 'active' in vals and vals['active'] is False:
self.env['mail.activity'].sudo().search(
[('res_model', '=', self._name), ('res_id', 'in', self.ids)]
).unlink()
return super(MailActivityMixin, self).write(vals)
@api.multi
def unlink(self):
""" Override unlink to delete records activities through (res_model, res_id). """