2018-08-23 01:26:55 +02:00
|
|
|
# Copyright 2018 Eficent <http://www.eficent.com>
|
|
|
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
|
|
|
|
|
|
class MailActivity(models.Model):
|
|
|
|
|
2021-08-13 12:50:46 +02:00
|
|
|
_inherit = "mail.activity"
|
2018-08-23 01:26:55 +02:00
|
|
|
|
2019-06-11 16:42:58 +02:00
|
|
|
active = fields.Boolean(default=True)
|
2018-08-23 01:26:55 +02:00
|
|
|
done = fields.Boolean(default=False)
|
2021-08-13 12:50:46 +02:00
|
|
|
state = fields.Selection(selection_add=[("done", "Done")], compute="_compute_state")
|
2018-08-23 01:26:55 +02:00
|
|
|
date_done = fields.Date(
|
2021-08-13 12:50:46 +02:00
|
|
|
"Completed Date",
|
|
|
|
index=True,
|
|
|
|
readonly=True,
|
2018-08-23 01:26:55 +02:00
|
|
|
)
|
|
|
|
|
2021-08-13 12:50:46 +02:00
|
|
|
@api.depends("date_deadline", "done")
|
2018-08-23 01:26:55 +02:00
|
|
|
def _compute_state(self):
|
|
|
|
super(MailActivity, self)._compute_state()
|
|
|
|
for record in self.filtered(lambda activity: activity.done):
|
2021-08-13 12:50:46 +02:00
|
|
|
record.state = "done"
|
2019-06-11 16:42:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MailActivityMixin(models.AbstractModel):
|
|
|
|
|
2021-08-13 12:50:46 +02:00
|
|
|
_inherit = "mail.activity.mixin"
|
2019-06-11 16:42:58 +02:00
|
|
|
activity_ids = fields.One2many(
|
2021-08-13 12:50:46 +02:00
|
|
|
domain=lambda self: [("res_model", "=", self._name), ("active", "=", True)]
|
|
|
|
)
|