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