Browse Source

[ADD] uninstall_hook to remove done activities

pull/380/head
Adrià Gil Sorribes 6 years ago
parent
commit
b889c7c6e0
  1. 2
      mail_activity_done/__init__.py
  2. 2
      mail_activity_done/__manifest__.py
  3. 12
      mail_activity_done/hooks.py

2
mail_activity_done/__init__.py

@ -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

2
mail_activity_done/__manifest__.py

@ -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',
} }

12
mail_activity_done/hooks.py

@ -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
"""
)
Loading…
Cancel
Save