diff --git a/mail_activity_done/__init__.py b/mail_activity_done/__init__.py index 74fbdef2..320b63a4 100644 --- a/mail_activity_done/__init__.py +++ b/mail_activity_done/__init__.py @@ -1,2 +1,2 @@ from . import models -from .hooks import post_load_hook, pre_init_hook +from .hooks import post_load_hook, pre_init_hook, uninstall_hook diff --git a/mail_activity_done/__manifest__.py b/mail_activity_done/__manifest__.py index f539b3d7..3f52695d 100644 --- a/mail_activity_done/__manifest__.py +++ b/mail_activity_done/__manifest__.py @@ -2,7 +2,7 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). { "name": "Mail Activity Done", - "version": "12.0.1.1.0", + "version": "12.0.2.0.0", "author": "Eficent," "Odoo Community Association (OCA)", "license": "LGPL-3", @@ -16,5 +16,5 @@ ], "pre_init_hook": "pre_init_hook", "post_load": "post_load_hook", - + 'uninstall_hook': 'uninstall_hook', } diff --git a/mail_activity_done/hooks.py b/mail_activity_done/hooks.py index 619cd44f..ebc5a575 100644 --- a/mail_activity_done/hooks.py +++ b/mail_activity_done/hooks.py @@ -39,6 +39,7 @@ def post_load_hook(): for activity in self: record = self.env[activity.res_model].browse(activity.res_id) activity.done = True + activity.active = False activity.date_done = fields.Date.today() record.message_post_with_view( 'mail.message_activity_done', @@ -52,3 +53,15 @@ def post_load_hook(): if not hasattr(MailActivity, 'action_feedback_original'): MailActivity.action_feedback_original = MailActivity.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 + """ + ) diff --git a/mail_activity_done/migrations/12.0.2.0.0/post-migration.py b/mail_activity_done/migrations/12.0.2.0.0/post-migration.py new file mode 100644 index 00000000..b163a08a --- /dev/null +++ b/mail_activity_done/migrations/12.0.2.0.0/post-migration.py @@ -0,0 +1,12 @@ +# Copyright 2019 Eficent +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + + +def migrate(cr, version): + if not version: + return + cr.execute(""" + UPDATE mail_activity SET + active = False + WHERE done=True; + """) diff --git a/mail_activity_done/models/mail_activity.py b/mail_activity_done/models/mail_activity.py index c91e9003..593a3571 100644 --- a/mail_activity_done/models/mail_activity.py +++ b/mail_activity_done/models/mail_activity.py @@ -7,6 +7,7 @@ class MailActivity(models.Model): _inherit = 'mail.activity' + active = fields.Boolean(default=True) done = fields.Boolean(default=False) state = fields.Selection(selection_add=[ ('done', 'Done')], compute='_compute_state') @@ -19,3 +20,11 @@ class MailActivity(models.Model): super(MailActivity, self)._compute_state() for record in self.filtered(lambda activity: activity.done): record.state = 'done' + + +class MailActivityMixin(models.AbstractModel): + + _inherit = 'mail.activity.mixin' + activity_ids = fields.One2many( + domain=lambda self: [('res_model', '=', self._name), + ('active', '=', True)]) diff --git a/mail_activity_done/models/res_users.py b/mail_activity_done/models/res_users.py index 8d81aa63..69bac79c 100644 --- a/mail_activity_done/models/res_users.py +++ b/mail_activity_done/models/res_users.py @@ -44,6 +44,7 @@ class ResUsers(models.Model): self.env[activity['model']]._original_module), 'total_count': 0, 'today_count': 0, 'overdue_count': 0, 'planned_count': 0, + 'type': 'activity', } user_activities[activity['model']][ '%s_count' % activity['states']] += activity['count'] diff --git a/mail_activity_done/views/mail_activity_views.xml b/mail_activity_done/views/mail_activity_views.xml index e3d49e47..ee095c2b 100644 --- a/mail_activity_done/views/mail_activity_views.xml +++ b/mail_activity_done/views/mail_activity_views.xml @@ -27,19 +27,41 @@ - - + + - [('date_deadline', '<', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)] + [('date_deadline', '<', context_today().strftime('%Y-%m-%d'))] - [('date_deadline', '=', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)] + [('date_deadline', '=', context_today().strftime('%Y-%m-%d'))] - [('date_deadline', '>', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)] + [('date_deadline', '>', context_today().strftime('%Y-%m-%d'))] + + + + + + res.partner.view.search.inherit.mail + res.partner + + + + + + + + [('activity_ids.date_deadline', '<', context_today().strftime('%Y-%m-%d'))] + + + [('activity_ids.date_deadline', '=', context_today().strftime('%Y-%m-%d'))] + + + [('activity_ids.date_deadline', '>', context_today().strftime('%Y-%m-%d'))]