From e2b3d50ca94af43c7058484bc4d81a7a981928e1 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 14 Mar 2016 11:47:08 +0100 Subject: [PATCH] =?UTF-8?q?[FIX]=C2=A0crm:=20deleting=20a=20crm.activity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- addons/crm/models/crm_activity.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/crm/models/crm_activity.py b/addons/crm/models/crm_activity.py index b2f211d6fdb..46592fd9134 100644 --- a/addons/crm/models/crm_activity.py +++ b/addons/crm/models/crm_activity.py @@ -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() \ No newline at end of file