mail_thread.py 758 B

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import models
  4. from odoo import api
  5. class MailThread(models.AbstractModel):
  6. _inherit = 'mail.thread'
  7. def _notify_cancel_snail(self):
  8. author_id = self.env.user.id
  9. letters = self.env['snailmail.letter'].search([
  10. ('state', 'not in', ['sent', 'canceled', 'pending']),
  11. ('user_id', '=', author_id),
  12. ('model', '=', self._name)
  13. ])
  14. letters.cancel()
  15. @api.model
  16. def notify_cancel_by_type(self, notification_type):
  17. super().notify_cancel_by_type(notification_type)
  18. if notification_type == 'snail':
  19. self._notify_cancel_snail()
  20. return True