Fixes to bemade_mail_cow_integration config param usage.
This commit is contained in:
parent
988a28a9d3
commit
656df081a1
4 changed files with 27 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
{
|
{
|
||||||
'name': 'Mailcow Integration',
|
'name': 'Mailcow Integration',
|
||||||
'version': '1.0.0',
|
'version': '15.0.1.0.1',
|
||||||
'category': 'Administration',
|
'category': 'Administration',
|
||||||
'summary': 'Module for integrating Mailcow email server with Odoo.',
|
'summary': 'Module for integrating Mailcow email server with Odoo.',
|
||||||
'description': """
|
'description': """
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(cr, version):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
settings = env['ir.config_parameter']
|
||||||
|
create_param = settings.get_param('mailcow.create_mailbox')
|
||||||
|
sync_param = settings.get_param('mailcow.sync_alias')
|
||||||
|
base_url = settings.get_param('mailcow.base_url')
|
||||||
|
api_key = settings.get_param('mailcow.api_key')
|
||||||
|
|
||||||
|
if (create_param or sync_param) and (not base_url or not api_key):
|
||||||
|
(create_param | sync_param).write({'value': False})
|
||||||
|
|
@ -8,8 +8,12 @@ class MailAlias(models.Model):
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
|
params = self.env['ir.config_parameter'].sudo()
|
||||||
|
param_auto_create = params.get_param('mailcow.create_mailbox')
|
||||||
|
|
||||||
alias = super(MailAlias, self).create(vals)
|
alias = super(MailAlias, self).create(vals)
|
||||||
if not alias.alias_name:
|
|
||||||
|
if not alias.alias_name or not param_auto_create:
|
||||||
return alias
|
return alias
|
||||||
|
|
||||||
alias_domain = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain"),
|
alias_domain = self.env["ir.config_parameter"].sudo().get_param("mail.catchall.domain"),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from odoo import fields, models
|
from odoo import fields, models, api, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class ResConfigSettings(models.TransientModel):
|
class ResConfigSettings(models.TransientModel):
|
||||||
_inherit = 'res.config.settings'
|
_inherit = 'res.config.settings'
|
||||||
|
|
@ -23,3 +25,8 @@ class ResConfigSettings(models.TransientModel):
|
||||||
string='Create Mailboxes in Mailcow',
|
string='Create Mailboxes in Mailcow',
|
||||||
help='Auto create Mailboxes in Mailcow on creation in Odoo',
|
help='Auto create Mailboxes in Mailcow on creation in Odoo',
|
||||||
config_parameter='mailcow.create_mailbox')
|
config_parameter='mailcow.create_mailbox')
|
||||||
|
|
||||||
|
@api.constrains('mailcow_sync_alias', 'mailcow_auto_create')
|
||||||
|
def require_api_key_and_base_url_to_sync(self):
|
||||||
|
if not self.mailcow_api_key and self.mailcow_base_url:
|
||||||
|
raise ValidationError(_("You must set a base URL and API key to enable synchronization."))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue