From 6ac675f50f5b6e6fb8074107dc58be42e57fa304 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Thu, 19 Dec 2019 09:54:15 +0000 Subject: [PATCH] [IMP] mail: support custom `x_active` field An override of toggle_active was present to ensure that activities would be removed before archiving records; this commit adapts this mechanism to take custom active fields into account, since they are now supported at ORM-level by getting the active field through the `_active_name` model attribute instead of blindly using the `active` hard-coded field that was used until now.. closes odoo/odoo#40109 Signed-off-by: Damien Bouvy (dbo) --- addons/mail/models/mail_activity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 933cca5d48d..d1e1941f163 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -701,7 +701,7 @@ class MailActivityMixin(models.AbstractModel): """ Before archiving the record we should also remove its ongoing activities. Otherwise they stay in the systray and concerning archived records it makes no sense. """ - record_to_deactivate = self.filtered(lambda rec: rec.active) + record_to_deactivate = self.filtered(lambda rec: rec[rec._active_name]) if record_to_deactivate: # use a sudo to bypass every access rights; all activities should be removed self.env['mail.activity'].sudo().search([