You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
958 B

  1. # Copyright 2018 Eficent <http://www.eficent.com>
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  3. from odoo import api, fields, models
  4. class MailActivity(models.Model):
  5. _inherit = 'mail.activity'
  6. active = fields.Boolean(default=True)
  7. done = fields.Boolean(default=False)
  8. state = fields.Selection(selection_add=[
  9. ('done', 'Done')], compute='_compute_state')
  10. date_done = fields.Date(
  11. 'Completed Date', index=True, readonly=True,
  12. )
  13. @api.depends('date_deadline', 'done')
  14. def _compute_state(self):
  15. super(MailActivity, self)._compute_state()
  16. for record in self.filtered(lambda activity: activity.done):
  17. record.state = 'done'
  18. class MailActivityMixin(models.AbstractModel):
  19. _inherit = 'mail.activity.mixin'
  20. activity_ids = fields.One2many(
  21. domain=lambda self: [('res_model', '=', self._name),
  22. ('active', '=', True)])