[ADD] uninstall_hook to remove done activities

This commit is contained in:
Adrià Gil Sorribes 2019-05-07 17:25:20 +02:00 committed by Bernat Puig Font
parent 437b0e9502
commit 99810d0174
3 changed files with 14 additions and 2 deletions

View File

@ -1,2 +1,2 @@
from . import models from . import models
from .hooks import post_load_hook, pre_init_hook from .hooks import post_load_hook, pre_init_hook, uninstall_hook

View File

@ -16,5 +16,5 @@
], ],
"pre_init_hook": "pre_init_hook", "pre_init_hook": "pre_init_hook",
"post_load": "post_load_hook", "post_load": "post_load_hook",
'uninstall_hook': 'uninstall_hook',
} }

View File

@ -52,3 +52,15 @@ def post_load_hook():
if not hasattr(MailActivity, 'action_feedback_original'): if not hasattr(MailActivity, 'action_feedback_original'):
MailActivity.action_feedback_original = MailActivity.action_feedback MailActivity.action_feedback_original = MailActivity.action_feedback
MailActivity.action_feedback = new_action_feedback MailActivity.action_feedback = new_action_feedback
def uninstall_hook(cr, registry):
""" The objective of this hook is to remove all activities that are done
upon module uninstall
"""
cr.execute(
"""
DELETE FROM mail_activity
WHERE done=True
"""
)