[REF] snailmail(_account): remove unused snailmail.confirm wizard
Snailmail holds an abstract model 'snailmail.confirm' that implements some kind of generic confirmation flow. It is nowadays used in a single case that is the 'snailmail.confirm.invoice' wizard that inherits of it in snailmail_account. In this commit we remove the base abstract model, as it is defined once and does not really add value. This kind of generic model actually adds more noise than solves issues. The invoice confirmation wizard is now completely defined in snailmail account bridge, easing understanding of models. Task-3046371 (Mail: Better Language Support in Composer) closes odoo/odoo#111901 Related: odoo/upgrade#4299 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -15,7 +15,6 @@ Allows users to send documents by post
|
||||
'data/snailmail_data.xml',
|
||||
'views/report_assets.xml',
|
||||
'views/snailmail_views.xml',
|
||||
'wizard/snailmail_confirm_views.xml',
|
||||
'wizard/snailmail_letter_format_error_views.xml',
|
||||
'wizard/snailmail_letter_missing_required_fields_views.xml',
|
||||
'security/ir.model.access.csv',
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from . import snailmail_confirm
|
||||
from . import snailmail_letter_format_error
|
||||
from . import snailmail_letter_missing_required_fields
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
# -*- 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
|
||||
@@ -11,6 +11,7 @@ Allows users to send invoices by post
|
||||
'data': [
|
||||
'views/res_config_settings_views.xml',
|
||||
'wizard/account_invoice_send_views.xml',
|
||||
'wizard/snailmail_confirm_invoice_views.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'auto_install': True,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import account_invoice_send
|
||||
from . import snailmail_confirm_invoice_send
|
||||
from . import snailmail_confirm_invoice
|
||||
|
||||
@@ -65,7 +65,7 @@ class AccountInvoiceSend(models.TransientModel):
|
||||
def send_and_print_action(self):
|
||||
if self.snailmail_is_letter:
|
||||
if self.env['snailmail.confirm.invoice'].show_warning():
|
||||
wizard = self.env['snailmail.confirm.invoice'].create({'model_name': _('Invoice'), 'invoice_send_id': self.id})
|
||||
wizard = self.env['snailmail.confirm.invoice'].create({'invoice_send_id': self.id})
|
||||
return wizard.action_open()
|
||||
self._print_action()
|
||||
return self.send_and_print()
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class SnailmailConfirmInvoiceSend(models.TransientModel):
|
||||
_name = 'snailmail.confirm.invoice'
|
||||
_description = 'Snailmail Confirm Invoice'
|
||||
|
||||
invoice_send_id = fields.Many2one('account.invoice.send')
|
||||
|
||||
def action_open(self):
|
||||
view = self.env.ref('snailmail_account.snailmail_confirm_invoice_view_form')
|
||||
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.ensure_one()
|
||||
self.env['ir.config_parameter'].sudo().set_param('snailmail.confirm.invoice.warning_shown', True)
|
||||
return self.invoice_send_id._print_action()
|
||||
|
||||
def action_cancel(self):
|
||||
self.ensure_one()
|
||||
self.env['ir.config_parameter'].sudo().set_param('snailmail.confirm.invoice.warning_shown', True)
|
||||
return self.invoice_send_id.send_and_print_action()
|
||||
|
||||
@api.model
|
||||
def show_warning(self):
|
||||
return not self.env['ir.config_parameter'].sudo().get_param('snailmail.confirm.invoice.warning_shown', False)
|
||||
@@ -1,20 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SnailmailConfirmInvoiceSend(models.TransientModel):
|
||||
_name = 'snailmail.confirm.invoice'
|
||||
_inherit = ['snailmail.confirm']
|
||||
_description = 'Snailmail Confirm Invoice'
|
||||
|
||||
invoice_send_id = fields.Many2one('account.invoice.send')
|
||||
|
||||
def _confirm(self):
|
||||
self.ensure_one()
|
||||
self.invoice_send_id._print_action()
|
||||
|
||||
def _continue(self):
|
||||
self.ensure_one()
|
||||
return self.invoice_send_id.send_and_print()
|
||||
+5
-4
@@ -1,11 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="snailmail_confirm_view" model="ir.ui.view">
|
||||
<field name="name">snailmail.confirm.view</field>
|
||||
<field name="model">snailmail.confirm</field>
|
||||
<record id="snailmail_confirm_invoice_view_form" model="ir.ui.view">
|
||||
<field name="name">snailmail.confirm.invoice.view.form</field>
|
||||
<field name="model">snailmail.confirm.invoice</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Snailmail Confirmation">
|
||||
<p>You are about to send this <field name="model_name" readonly="1" class="oe_inline" /> by post. Are you sure you want to continue?</p>
|
||||
<field name="invoice_send_id" invisible="1"/>
|
||||
<p>You are about to send this Invoice by post. Are you sure you want to continue?</p>
|
||||
<footer>
|
||||
<button string="Confirm" name="action_confirm" type="object" class="btn-primary" data-hotkey="q"/>
|
||||
<button string="Cancel" name="action_cancel" type="object" class="btn-secondary" data-hotkey="x"/>
|
||||
Reference in New Issue
Block a user