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

This commit is contained in:
Jordi Ballester Alomar 2019-06-11 16:42:58 +02:00 committed by Bernat Puig Font
parent ccacf8b437
commit 49d8235387
7 changed files with 53 additions and 14 deletions

View File

@ -2,7 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{ {
"name": "Mail Activity Done", "name": "Mail Activity Done",
"version": "12.0.1.2.0", "version": "12.0.2.0.0",
"author": "Eficent," "author": "Eficent,"
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"license": "LGPL-3", "license": "LGPL-3",

View File

@ -39,6 +39,7 @@ def post_load_hook():
for activity in self: for activity in self:
record = self.env[activity.res_model].browse(activity.res_id) record = self.env[activity.res_model].browse(activity.res_id)
activity.done = True activity.done = True
activity.active = False
activity.date_done = fields.Date.today() activity.date_done = fields.Date.today()
record.message_post_with_view( record.message_post_with_view(
'mail.message_activity_done', 'mail.message_activity_done',

View File

@ -20,13 +20,31 @@ msgstr ""
msgid "%d days overdue" msgid "%d days overdue"
msgstr "" msgstr ""
#. module: mail_activity_done
#: model:ir.model.fields,field_description:mail_activity_done.field_mail_activity__active
msgid "Active"
msgstr ""
#. module: mail_activity_done
#: model:ir.model.fields,field_description:mail_activity_done.field_mail_activity_mixin__activity_ids
#: model:ir.model.fields,field_description:mail_activity_done.field_res_partner__activity_ids
#: model:ir.model.fields,field_description:mail_activity_done.field_res_users__activity_ids
msgid "Activities"
msgstr ""
#. module: mail_activity_done #. module: mail_activity_done
#: model:ir.model,name:mail_activity_done.model_mail_activity #: model:ir.model,name:mail_activity_done.model_mail_activity
msgid "Activity" msgid "Activity"
msgstr "" msgstr ""
#. module: mail_activity_done
#: model:ir.model,name:mail_activity_done.model_mail_activity_mixin
msgid "Activity Mixin"
msgstr ""
#. module: mail_activity_done #. module: mail_activity_done
#: model_terms:ir.ui.view,arch_db:mail_activity_done.mail_activity_view_search #: model_terms:ir.ui.view,arch_db:mail_activity_done.mail_activity_view_search
#: model_terms:ir.ui.view,arch_db:mail_activity_done.res_partner_view_search_inherit_mail
msgid "Completed Activities" msgid "Completed Activities"
msgstr "" msgstr ""
@ -49,7 +67,7 @@ msgid "Due in %d days"
msgstr "" msgstr ""
#. module: mail_activity_done #. module: mail_activity_done
#: model_terms:ir.ui.view,arch_db:mail_activity_done.mail_activity_view_search #: model_terms:ir.ui.view,arch_db:mail_activity_done.res_partner_view_search_inherit_mail
msgid "Open Activities" msgid "Open Activities"
msgstr "" msgstr ""

View File

@ -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;
""")

View File

@ -7,6 +7,7 @@ class MailActivity(models.Model):
_inherit = 'mail.activity' _inherit = 'mail.activity'
active = fields.Boolean(default=True)
done = fields.Boolean(default=False) done = fields.Boolean(default=False)
state = fields.Selection(selection_add=[ state = fields.Selection(selection_add=[
('done', 'Done')], compute='_compute_state') ('done', 'Done')], compute='_compute_state')
@ -19,3 +20,11 @@ class MailActivity(models.Model):
super(MailActivity, self)._compute_state() super(MailActivity, self)._compute_state()
for record in self.filtered(lambda activity: activity.done): for record in self.filtered(lambda activity: activity.done):
record.state = '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)])

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Mail Activity Done</title> <title>Mail Activity Done</title>
<style type="text/css"> <style type="text/css">

View File

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