[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) <dbo@odoo.com>
This commit is contained in:
Damien Bouvy
2019-12-20 11:16:01 +00:00
parent 59eee6ba5f
commit 6ac675f50f
+1 -1
View File
@@ -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([