Mailcow mailbox client-side sync button.
This commit is contained in:
parent
ed021edc40
commit
f7de7d31af
5 changed files with 41 additions and 33 deletions
|
|
@ -33,8 +33,11 @@ Main Features:
|
||||||
],
|
],
|
||||||
"assets": {
|
"assets": {
|
||||||
"web.assets_backend": [
|
"web.assets_backend": [
|
||||||
"bemade_mailcow_blacklist/static/src/js/mailcow_mailbox.js"
|
"bemade_mailcow_blacklist/static/src/js/mailcow_mailbox.js",
|
||||||
]
|
],
|
||||||
|
"web.assets_qweb": [
|
||||||
|
"bemade_mailcow_blacklist/static/src/xml/mailcow_mailbox.xml",
|
||||||
|
],
|
||||||
},
|
},
|
||||||
'demo': [],
|
'demo': [],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class MailcowMailbox(models.Model):
|
||||||
for record in self:
|
for record in self:
|
||||||
record.address = f"{record.local_part}@{record.domain}"
|
record.address = f"{record.local_part}@{record.domain}"
|
||||||
|
|
||||||
|
@api.model
|
||||||
def sync_mailboxes(self):
|
def sync_mailboxes(self):
|
||||||
"""
|
"""
|
||||||
Synchronize Mailcow mailboxes with Odoo
|
Synchronize Mailcow mailboxes with Odoo
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,27 @@
|
||||||
odoo.define('bemade_mailcow_blacklist.mailcow_mailbox', function (require) {
|
/** @odoo-module **/
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var core = require('web.core');
|
import ListController from 'web.ListController';
|
||||||
var ListController = require('web.ListController');
|
import ListView from 'web.ListView';
|
||||||
var ListView = require('web.ListView');
|
const viewRegistry = require('web.view_registry');
|
||||||
var viewRegistry = require('web.view_registry');
|
|
||||||
|
|
||||||
var MailboxesListController = ListController.extend({
|
const MailboxesListController = ListController.extend({
|
||||||
buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
|
buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
|
||||||
events: _.extend({}, ListController.prototype.events, {
|
events: _.extend({}, ListController.prototype.events, {
|
||||||
'click .o_button_sync_mailboxes': '_onSyncMailboxes',
|
'click .o_button_sync_mailboxes': '_onSyncMailboxes',
|
||||||
}),
|
}),
|
||||||
_onSyncMailboxes: function () {
|
_onSyncMailboxes: function () {
|
||||||
this._rpc({
|
this._rpc({
|
||||||
model: 'mail.mailcow.mailbox',
|
model: 'mail.mailcow.mailbox',
|
||||||
method: 'sync_mailboxes',
|
method: 'sync_mailboxes',
|
||||||
args: [],
|
args: [],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
|
||||||
var MailboxesListView = ListView.extend({
|
|
||||||
config: _.extend({}, ListView.prototype.config, {
|
|
||||||
Controller: MailboxesListController,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
viewRegistry.add('mail.mailcow.mailbox', MailboxesListView);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const MailboxesListView = ListView.extend({
|
||||||
|
config: _.extend({}, ListView.prototype.config, {
|
||||||
|
Controller: MailboxesListController,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
viewRegistry.add('mail_mailcow_mailbox_tree', MailboxesListView);
|
||||||
|
|
|
||||||
10
bemade_mailcow_blacklist/static/src/xml/mailcow_mailbox.xml
Normal file
10
bemade_mailcow_blacklist/static/src/xml/mailcow_mailbox.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<templates>
|
||||||
|
<t t-extend="ListView.buttons" t-name="mail.mailcow_mailbox_list_view_buttons">
|
||||||
|
<t t-jquery="button.o_list_button_add" t-operation="after">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-primary ml4 o_button_sync_mailboxes"
|
||||||
|
title="Sync Mailboxes"> Sync Mailboxes </button>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</templates>
|
||||||
|
|
@ -4,10 +4,7 @@
|
||||||
<field name="name">mailcow.mailbox.view.tree</field>
|
<field name="name">mailcow.mailbox.view.tree</field>
|
||||||
<field name="model">mail.mailcow.mailbox</field>
|
<field name="model">mail.mailcow.mailbox</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Mailbox" decoration-info="active == False">
|
<tree string="Mailbox" decoration-info="active == False" js_class="mail_mailcow_mailbox_tree">
|
||||||
<header>
|
|
||||||
<button name="sync_mailboxes" string="Sync with Mailcow" type="object"/>
|
|
||||||
</header>
|
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="local_part"/>
|
<field name="local_part"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue