fix mailcow
This commit is contained in:
parent
12ed7b8ce5
commit
8201461c61
4 changed files with 69 additions and 31 deletions
|
|
@ -18,3 +18,8 @@ class ResConfigSettings(models.TransientModel):
|
||||||
string='Sync Aliases with Odoo',
|
string='Sync Aliases with Odoo',
|
||||||
help='Auto create Aliases in Mailcow from Odoo',
|
help='Auto create Aliases in Mailcow from Odoo',
|
||||||
config_parameter='mailcow.sync_alias')
|
config_parameter='mailcow.sync_alias')
|
||||||
|
|
||||||
|
mailcow_auto_create = fields.Boolean(
|
||||||
|
string='Create Mailboxes in Mailcow',
|
||||||
|
help='Auto create Mailboxes in Mailcow on creation in Odoo',
|
||||||
|
config_parameter='mailcow.create_mailbox')
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,34 @@ from odoo import models, fields, api
|
||||||
class ResUsers(models.Model):
|
class ResUsers(models.Model):
|
||||||
_inherit = 'res.users'
|
_inherit = 'res.users'
|
||||||
|
|
||||||
|
# def _compute_create_mailcow_mailbox(self):
|
||||||
|
# params = self.env['ir.config_parameter'].sudo()
|
||||||
|
# can_create = params.get_param('mailcow.create_mailbox')
|
||||||
|
# return can_create
|
||||||
|
|
||||||
mailcow_mailbox = fields.Boolean(string='Mailcow Mailbox', default=False)
|
mailcow_mailbox = fields.Boolean(string='Mailcow Mailbox', default=False)
|
||||||
|
|
||||||
|
# can_create_mailcow_mailbox = fields.Boolean(
|
||||||
|
# string='Create Mailcow Mailbox',
|
||||||
|
# compute=_compute_create_mailcow_mailbox
|
||||||
|
# )
|
||||||
|
|
||||||
|
mailcow_auto_create = fields.Boolean(compute='_compute_mailcow_auto_create', string='Create Mailbox in Mailcow')
|
||||||
|
|
||||||
|
|
||||||
|
def _compute_mailcow_auto_create(self):
|
||||||
|
for rec in self:
|
||||||
|
config = self.env['ir.config_parameter'].sudo()
|
||||||
|
get_mailcow_auto_create = config.get_param('mailcow_auto_create', False)
|
||||||
|
rec.mailcow_auto_create = get_mailcow_auto_create
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
res = super(ResUsers, self).create(vals)
|
res = super(ResUsers, self).create(vals)
|
||||||
|
|
||||||
if vals.get('mailcow_mailbox', false):
|
if res.mailcow_mailbox:
|
||||||
self.env['mail.mailcow.mailbox'].create_mailbox_for_user(res)
|
self.env['mail.mailcow.mailbox'].create_mailbox_for_user(res)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,29 +8,44 @@
|
||||||
<div id="emails" position='after'>
|
<div id="emails" position='after'>
|
||||||
<div id="mailcow">
|
<div id="mailcow">
|
||||||
<h2>Mailcow Settings</h2>
|
<h2>Mailcow Settings</h2>
|
||||||
<div class="row mt16 o_settings_container">
|
<div class="row mt16 o_settings_container" name="mailcow_setting">
|
||||||
<div class="col-12 col-lg-6 o_setting_box">
|
<div class="col-xs-12 col-md-6 o_setting_box" id="mail_setting_creds">
|
||||||
<label for="mailcow_base_url" string="Mailcow URL"/>
|
<div class="o_setting_right_pane" id="mailcow_settings_creds_settings">
|
||||||
<div class="text-muted">
|
<label for="mailcow_base_url" string="Mailcow URL"/>
|
||||||
Base URL for Mailcow server
|
<div class="text-muted">
|
||||||
|
Base URL for Mailcow server
|
||||||
|
</div>
|
||||||
|
<div class="content-group">
|
||||||
|
<field name="mailcow_base_url"/>
|
||||||
|
</div>
|
||||||
|
<label for="mailcow_api_key" string="API Key"/>
|
||||||
|
<div class="text-muted">
|
||||||
|
Mailcow API Key
|
||||||
|
</div>
|
||||||
|
<div class="content-group">
|
||||||
|
<field name="mailcow_api_key"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-group">
|
</div>
|
||||||
<field name="mailcow_base_url"/>
|
<div class="col-xs-12 col-md-6 o_setting_box" name="mailcow_setting_options">
|
||||||
</div>
|
<div class="o_setting_left_pane">
|
||||||
<label for="mailcow_api_key" string="API Key"/>
|
|
||||||
<div class="text-muted">
|
|
||||||
Mailcow API Key
|
|
||||||
</div>
|
|
||||||
<div class="content-group">
|
|
||||||
<field name="mailcow_api_key"/>
|
|
||||||
</div>
|
|
||||||
<label for="mailcow_sync_alias" string="Sync Aliases with Odoo'"/>
|
|
||||||
<div class="text-muted">
|
|
||||||
Auto create Aliases in Mailcow from Odoo
|
|
||||||
</div>
|
|
||||||
<div class="content-group">
|
|
||||||
<field name="mailcow_sync_alias"/>
|
<field name="mailcow_sync_alias"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="mailcow_sync_alias" string="Sync Aliases with Odoo"/>
|
||||||
|
<div class="text-muted">
|
||||||
|
Auto create Aliases in Mailcow from Odoo
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_left_pane">
|
||||||
|
<field name="mailcow_auto_create"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="mailcow_auto_create" string="Create mailbox in Mailcow"/>
|
||||||
|
<div class="text-muted">
|
||||||
|
Auto create Mailbox in Mailcow on creation in Odoo
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,12 @@
|
||||||
<field name="model">res.users</field>
|
<field name="model">res.users</field>
|
||||||
<field name="inherit_id" ref="base.view_users_form"/>
|
<field name="inherit_id" ref="base.view_users_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<data>
|
<field name="email" position="before">
|
||||||
<xpath expr="//notebook" position="inside">
|
<div id="mailcow_mailcow" attrs="{'invisible': [('id', '!=', False)]}">
|
||||||
<page string="Mailcow" name="mailcow">
|
<label for="mailcow_mailbox" string="Create mailbox on Mailcow"/>
|
||||||
<group>
|
<field name="mailcow_mailbox"/>
|
||||||
<field name="mailcow_mailbox"/>
|
</div>
|
||||||
</group>
|
</field>
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
</data>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue