[FIX] crm: deleting a crm.activity

crm.activity inherits mail.message.subtype with the field subtype_id
Before rendering "chatter.ChatComposer", the internal subtypes are fetched
on model mail.message.subtype(in function "fields_view_get").
But when deleting a crm.activity, the linked mail.message.subtype was not
deleted.

Used case:

When deleting a crm.activity, the activity still appeared in the chatter
if you log an internal note for an opportunity as an employee.

opw:670654
This commit is contained in:
Goffin Simon
2016-03-14 13:30:21 +01:00
parent 000ce6a66d
commit e2b3d50ca9
+8
View File
@@ -45,3 +45,11 @@ class CrmActivity(models.Model):
if 'internal' not in values and 'default_internal' not in self._context:
values['internal'] = True
return super(CrmActivity, self).create(values)
@api.multi
def unlink(self):
activities = self.search([('subtype_id', '=', self.subtype_id.id)])
# to ensure that the subtype is only linked the current activity
if len(activities) == 1:
self.subtype_id.unlink()
return super(CrmActivity, self).unlink()