1# -*- coding: utf-8 -*- 2# Part of Odoo. See LICENSE file for full copyright and licensing details. 3 4from odoo import api, fields, models, _ 5 6 7class SnailmailConfirm(models.AbstractModel): 8 _name = 'snailmail.confirm' 9 _description = 'Snailmail Confirm' 10 11 model_name = fields.Char() 12 13 @api.model 14 def show_warning(self): 15 return not self.env['ir.config_parameter'].sudo().get_param('%s.warning_shown' % self._name, False) 16 17 def action_open(self): 18 view = self.env.ref('snailmail.snailmail_confirm_view') 19 return { 20 'name': _('Snailmail'), 21 'type': 'ir.actions.act_window', 22 'view_mode': 'form', 23 'res_model': self._name, 24 'views': [(view.id, 'form')], 25 'view_id': view.id, 26 'target': 'new', 27 'res_id': self.id, 28 'context': self.env.context 29 } 30 31 def action_confirm(self): 32 self.env['ir.config_parameter'].sudo().set_param('%s.warning_shown' % self._name, True) 33 self._confirm() 34 return self._continue() 35 36 def action_cancel(self): 37 self.env['ir.config_parameter'].sudo().set_param('%s.warning_shown' % self._name, True) 38 return self._continue() 39 40 """ 41 Called whether the user confirms or cancels posting the letter, e.g. to continue the action 42 """ 43 def _continue(self): 44 pass 45 46 """ 47 Called only when the user confirms sending the letter 48 """ 49 def _confirm(self): 50 pass 51