[NEW] Automatic install mailhog. Mailhog integration in Odoo
This commit is contained in:
3
mailcatcher_menu/wizard/__init__.py
Normal file
3
mailcatcher_menu/wizard/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import install_warning_wizard
|
||||
43
mailcatcher_menu/wizard/install_warning_wizard.py
Normal file
43
mailcatcher_menu/wizard/install_warning_wizard.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright 2024 Open2Bizz <info@open2bizz.nl>
|
||||
# License LGPL-3
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class MailcatcherInstallWarningWizard(models.TransientModel):
|
||||
_name = 'mailcatcher.install.warning.wizard'
|
||||
_description = 'MailCatcher Install Warning'
|
||||
|
||||
module_id = fields.Many2one('ir.module.module', string='Module', readonly=True)
|
||||
|
||||
def action_confirm_install(self):
|
||||
"""User confirmed — proceed with the actual module installation."""
|
||||
self.ensure_one()
|
||||
return self.module_id.with_context(
|
||||
skip_mailcatcher_warning=True
|
||||
).button_immediate_install()
|
||||
|
||||
|
||||
class IrModuleModule(models.Model):
|
||||
_inherit = 'ir.module.module'
|
||||
|
||||
def button_immediate_install(self):
|
||||
"""Override to show a warning before installing mailcatcher_menu."""
|
||||
if self.env.context.get('skip_mailcatcher_warning'):
|
||||
return super().button_immediate_install()
|
||||
|
||||
mailcatcher_modules = self.filtered(lambda m: m.name == 'mailcatcher_menu')
|
||||
if mailcatcher_modules:
|
||||
wizard = self.env['mailcatcher.install.warning.wizard'].create({
|
||||
'module_id': mailcatcher_modules[0].id,
|
||||
})
|
||||
return {
|
||||
'name': _('Install MailCatcher Module'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'mailcatcher.install.warning.wizard',
|
||||
'res_id': wizard.id,
|
||||
'view_mode': 'form',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
return super().button_immediate_install()
|
||||
28
mailcatcher_menu/wizard/install_warning_wizard_view.xml
Normal file
28
mailcatcher_menu/wizard/install_warning_wizard_view.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<odoo>
|
||||
<record id="view_mailcatcher_install_warning_wizard" model="ir.ui.view">
|
||||
<field name="name">mailcatcher.install.warning.wizard.form</field>
|
||||
<field name="model">mailcatcher.install.warning.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Install MailCatcher">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<h4 class="alert-heading">Warning</h4>
|
||||
<p>
|
||||
You are about to install the <strong>MailCatcher</strong> module.
|
||||
</p>
|
||||
<p>
|
||||
This will also install <strong>MailHog</strong> as a systemd service on this server.
|
||||
MailHog will listen on port <strong>8025</strong> (Web UI) and port <strong>1025</strong> (SMTP).
|
||||
</p>
|
||||
<p>
|
||||
Do you want to proceed with the installation?
|
||||
</p>
|
||||
</div>
|
||||
<footer>
|
||||
<button name="action_confirm_install" type="object"
|
||||
string="Confirm Install" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user