Files
odoo_source/addons/snailmail/wizard/snailmail_confirm.py
T
Kevin Baptiste b83e783700 [IMP] snailmail: confirm sending first letter
Show a confirmation dialog when a user is sending the very first letter.

=========
 Purpose
=========

It happens from time to time that a letter gets sent by accident to a
final customer. This situation is always a bit problematic and is
usually only uncovered when it is too late.  Having an additional
warning when sending the very first letter should help avoid that kind
of issue.

================
 Specifications
================

Display the following warning when the user tries to send a snailmail
letter for the first time (from an invoice or from a follow-up report):
'You are about to send this invoice/follow-up report by post. Are you
sure you want to continue?' Confirm/Cancel

closes odoo/odoo#47861

Taskid: 2215091
Related: odoo/enterprise#9326
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-04-16 09:36:04 +00:00

51 lines
1.5 KiB
Python

# -*- 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