Browse Source

[mail_activity_done] set activities as inactive when they have been completed.

pull/398/merge
Jordi Ballester Alomar 5 years ago
committed by Holger Brunn
parent
commit
8c4a24cf7f
  1. 2
      mail_activity_done/__manifest__.py
  2. 1
      mail_activity_done/hooks.py
  3. 12
      mail_activity_done/migrations/11.0.2.0.0/post-migration.py
  4. 9
      mail_activity_done/models/mail_activity.py
  5. 13
      mail_activity_done/views/mail_activity_views.xml

2
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": "11.0.1.1.0",
"version": "11.0.2.0.0",
"author": "Eficent,"
"Odoo Community Association (OCA)",
"license": "LGPL-3",

1
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',

12
mail_activity_done/migrations/11.0.2.0.0/post-migration.py

@ -0,0 +1,12 @@
# Copyright 2019 Eficent <http://www.eficent.com>
# 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;
""")

9
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)])

13
mail_activity_done/views/mail_activity_views.xml

@ -27,19 +27,18 @@
<field name="arch" type="xml">
<field name="res_model_id" position="after">
<field name="done"/>
<filter string="Open Activities" name="activities_open"
domain="[('done', '!=', True)]"/>
<filter string="Completed Activities" name="activities_completed"
domain="[('done', '=', True)]"/>
<field name="active"/>
<filter string="Completed Activities" name="activities_completed"
domain="[('active', '=', False), ('state', '=', 'done')]"/>
</field>
<filter name="activities_overdue" position="attributes">
<attribute name="domain">[('date_deadline', '&lt;', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)]</attribute>
<attribute name="domain">[('date_deadline', '&lt;', context_today().strftime('%Y-%m-%d'))]</attribute>
</filter>
<filter name="activities_today" position="attributes">
<attribute name="domain">[('date_deadline', '=', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)]</attribute>
<attribute name="domain">[('date_deadline', '=', context_today().strftime('%Y-%m-%d'))]</attribute>
</filter>
<filter name="activities_upcoming_all" position="attributes">
<attribute name="domain">[('date_deadline', '&gt;', context_today().strftime('%Y-%m-%d')), ('done', '!=', True)]</attribute>
<attribute name="domain">[('date_deadline', '&gt;', context_today().strftime('%Y-%m-%d'))]</attribute>
</filter>
</field>
</record>

Loading…
Cancel
Save