mail_template_reset.py 959 B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import fields, models, _
  4. class MailTemplateReset(models.TransientModel):
  5. _name = 'mail.template.reset'
  6. _description = 'Mail Template Reset'
  7. template_ids = fields.Many2many('mail.template')
  8. def reset_template(self):
  9. if not self.template_ids:
  10. return False
  11. self.template_ids.reset_template()
  12. if self.env.context.get('params', {}).get('view_type') == 'list':
  13. next_action = {'type': 'ir.actions.client', 'tag': 'reload'}
  14. else:
  15. next_action = {'type': 'ir.actions.act_window_close'}
  16. return {
  17. 'type': 'ir.actions.client',
  18. 'tag': 'display_notification',
  19. 'params': {
  20. 'type': 'success',
  21. 'message': _('Mail Templates have been reset'),
  22. 'next': next_action,
  23. }
  24. }