[NEW] Automatic install mailhog. Mailhog integration in Odoo
This commit is contained in:
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()
|
||||
Reference in New Issue
Block a user