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": {
|
||||
"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': [],
|
||||
'installable': True,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class MailcowMailbox(models.Model):
|
|||
for record in self:
|
||||
record.address = f"{record.local_part}@{record.domain}"
|
||||
|
||||
@api.model
|
||||
def sync_mailboxes(self):
|
||||
"""
|
||||
Synchronize Mailcow mailboxes with Odoo
|
||||
|
|
|
|||
|
|
@ -1,30 +1,27 @@
|
|||
odoo.define('bemade_mailcow_blacklist.mailcow_mailbox', function (require) {
|
||||
"use strict";
|
||||
/** @odoo-module **/
|
||||
|
||||
var core = require('web.core');
|
||||
var ListController = require('web.ListController');
|
||||
var ListView = require('web.ListView');
|
||||
var viewRegistry = require('web.view_registry');
|
||||
import ListController from 'web.ListController';
|
||||
import ListView from 'web.ListView';
|
||||
const viewRegistry = require('web.view_registry');
|
||||
|
||||
var MailboxesListController = ListController.extend({
|
||||
buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
|
||||
events: _.extend({}, ListController.prototype.events, {
|
||||
'click .o_button_sync_mailboxes': '_onSyncMailboxes',
|
||||
}),
|
||||
_onSyncMailboxes: function () {
|
||||
this._rpc({
|
||||
model: 'mail.mailcow.mailbox',
|
||||
method: 'sync_mailboxes',
|
||||
args: [],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
var MailboxesListView = ListView.extend({
|
||||
config: _.extend({}, ListView.prototype.config, {
|
||||
Controller: MailboxesListController,
|
||||
}),
|
||||
});
|
||||
|
||||
viewRegistry.add('mail.mailcow.mailbox', MailboxesListView);
|
||||
const MailboxesListController = ListController.extend({
|
||||
buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
|
||||
events: _.extend({}, ListController.prototype.events, {
|
||||
'click .o_button_sync_mailboxes': '_onSyncMailboxes',
|
||||
}),
|
||||
_onSyncMailboxes: function () {
|
||||
this._rpc({
|
||||
model: 'mail.mailcow.mailbox',
|
||||
method: 'sync_mailboxes',
|
||||
args: [],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
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="model">mail.mailcow.mailbox</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Mailbox" decoration-info="active == False">
|
||||
<header>
|
||||
<button name="sync_mailboxes" string="Sync with Mailcow" type="object"/>
|
||||
</header>
|
||||
<tree string="Mailbox" decoration-info="active == False" js_class="mail_mailcow_mailbox_tree">
|
||||
<field name="active"/>
|
||||
<field name="name"/>
|
||||
<field name="local_part"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue