diff --git a/bemade_mailcow_blacklist/__manifest__.py b/bemade_mailcow_blacklist/__manifest__.py
index 89b67d5..cdb0e36 100644
--- a/bemade_mailcow_blacklist/__manifest__.py
+++ b/bemade_mailcow_blacklist/__manifest__.py
@@ -19,7 +19,7 @@ Main Features:
""",
'sequence': 10,
'license': 'OPL-1',
- 'author': 'BeMade',
+ 'author': 'Bemade',
'website': 'https://www.bemade.org',
'depends': ['hr', 'mail', 'bemade_user_password_bundle'],
'data': [
@@ -33,14 +33,10 @@ Main Features:
],
"assets": {
"web.assets_backend": [
- "bemade_mailcow_blacklist/static/src/js/mailcow_mailbox.js",
- "bemade_mailcow_blacklist/static/src/js/mailcow_alias.js",
- "bemade_mailcow_blacklist/static/src/js/mailcow_blacklist.js",
+ "bemade_mailcow_blacklist/static/src/js/mailcow.js",
],
"web.assets_qweb": [
- "bemade_mailcow_blacklist/static/src/xml/mailcow_mailbox.xml",
- "bemade_mailcow_blacklist/static/src/xml/mailcow_alias.xml",
- "bemade_mailcow_blacklist/static/src/xml/mailcow_blacklist.xml",
+ "bemade_mailcow_blacklist/static/src/xml/mailcow_templates.xml",
],
},
'demo': [],
diff --git a/bemade_mailcow_blacklist/models/mailcow_alias.py b/bemade_mailcow_blacklist/models/mailcow_alias.py
index fa426f1..560b11b 100644
--- a/bemade_mailcow_blacklist/models/mailcow_alias.py
+++ b/bemade_mailcow_blacklist/models/mailcow_alias.py
@@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__)
class MailcowAlias(models.Model):
_name = 'mail.mailcow.alias'
_description = 'Mailcow Alias'
- _inherit = ['mail.thread', 'mail.activity.mixin']
+ _inherit = ['mail.mailcow', 'mail.thread', 'mail.activity.mixin']
_rec_name = 'address'
address = fields.Char(string='Alias Address', required=True, tracking=True)
@@ -16,6 +16,9 @@ class MailcowAlias(models.Model):
active = fields.Boolean(string='Active', default=True, tracking=True)
catchall = fields.Boolean(string='Catchall', default=False, tracking=True)
alias_id = fields.Many2one(comodel_name='mail.alias', string='Alias')
+ create_date_mailcow = fields.Datetime(string='Created on Mailcow', readonly=True)
+ modify_date_mailcow = fields.Datetime(string='Modified on Mailcow', readonly=True)
+ mc_id = fields.Integer(string='Mailcow ID', readonly=True)
_sql_constraints = [
('address_unique', 'UNIQUE(address)', 'The alias address must be unique!'),
@@ -27,8 +30,9 @@ class MailcowAlias(models.Model):
if 'mc_id' not in vals:
data = {
- "active": str(int(alias.active)),
+ "active": bool(alias.active),
"address": alias.address,
+ "catchall": bool(alias.catchall),
"goto": alias.goto,
"private_comment": f"Created by {self.env.user.name} on {fields.Datetime.now()}",
"public_comment": "Alias created in Odoo"
@@ -84,16 +88,21 @@ class MailcowAlias(models.Model):
alias_domain = self.env['ir.config_parameter'].sudo().get_param('mail.catchall.domain')
if domain == alias_domain:
- alias = self.search([('address', '=', mc_alias['address'])], limit=1)
+ alias = self.search([('mc_id', '=', mc_alias['id'])], limit=1)
if not alias:
self.create({
'address': mc_alias['address'],
- 'active': mc_alias['active'] == '1',
+ 'active': bool(mc_alias['active']),
'goto': mc_alias['goto'],
- 'domain': mc_alias['domain']
+ 'mc_id': mc_alias['id'],
+ 'create_date_mailcow': mc_alias['created'],
+ 'modify_date_mailcow': mc_alias['modified'],
})
else:
alias.write({
- 'active': mc_alias['active'] == '1',
- 'goto': mc_alias['goto']
+ 'address': mc_alias['address'],
+ 'active': bool(mc_alias['active']),
+ 'goto': mc_alias['goto'],
+ 'create_date_mailcow': mc_alias['created'],
+ 'modify_date_mailcow': mc_alias['modified'],
})
diff --git a/bemade_mailcow_blacklist/static/src/js/mailcow.js b/bemade_mailcow_blacklist/static/src/js/mailcow.js
new file mode 100644
index 0000000..d1a4ac4
--- /dev/null
+++ b/bemade_mailcow_blacklist/static/src/js/mailcow.js
@@ -0,0 +1,89 @@
+/** @odoo-module **/
+
+import ListController from 'web.ListController';
+import ListView from 'web.ListView';
+const viewRegistry = require('web.view_registry');
+
+const AliasesListController = ListController.extend({
+ // buttons_template must match the t-name on the template for the button (static xml)
+ buttons_template: 'mail.mailcow_aliases_list_view_buttons',
+ events: _.extend({}, ListController.prototype.events, {
+ 'click .o_button_sync_aliases': '_onSyncAliases',
+ }),
+ // This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
+ _onSyncAliases: function () {
+ this._rpc({
+ model: 'mail.mailcow.alias',
+ method: 'sync_aliases',
+ args: [],
+ }).then(() => {
+ this.reload();
+ });
+ // Couldn't test this for real, but it runs the action. May need a this.reload()
+ },
+});
+
+const AliasesListView = ListView.extend({
+ config: _.extend({}, ListView.prototype.config, {
+ Controller: AliasesListController,
+ }),
+});
+
+// key must match with the js_class attribute of the tree view you want to modify
+viewRegistry.add('mail_mailcow_aliases_tree', AliasesListView);
+
+const BlacklistListController = ListController.extend({
+ // buttons_template must match the t-name on the template for the button (static xml)
+ buttons_template: 'mail.mailcow_blacklist_list_view_buttons',
+ events: _.extend({}, ListController.prototype.events, {
+ 'click .o_button_sync_blacklist': '_onSyncBlacklist',
+ }),
+ // This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
+ _onSyncBlacklist: function () {
+ this._rpc({
+ model: 'mail.mailcow.blacklist',
+ method: 'sync_blacklist',
+ args: [],
+ }).then(() => {
+ this.reload();
+ });
+ // Couldn't test this for real, but it runs the action. May need a this.reload()
+ },
+});
+
+const BlacklistListView = ListView.extend({
+ config: _.extend({}, ListView.prototype.config, {
+ Controller: BlacklistListController,
+ }),
+});
+
+// key must match with the js_class attribute of the tree view you want to modify
+viewRegistry.add('mail_mailcow_blacklist_tree', BlacklistListView);
+
+const MailboxesListController = ListController.extend({
+ // buttons_template must match the t-name on the template for the button (static xml)
+ buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
+ events: _.extend({}, ListController.prototype.events, {
+ 'click .o_button_sync_mailboxes': '_onSyncMailboxes',
+ }),
+ // This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
+ _onSyncMailboxes: function () {
+ this._rpc({
+ model: 'mail.mailcow.mailbox',
+ method: 'sync_mailboxes',
+ args: [],
+ }).then(() => {
+ this.reload();
+ });
+ // Couldn't test this for real, but it runs the action. May need a this.reload()
+ },
+});
+
+const MailboxesListView = ListView.extend({
+ config: _.extend({}, ListView.prototype.config, {
+ Controller: MailboxesListController,
+ }),
+});
+
+// key must match with the js_class attribute of the tree view you want to modify
+viewRegistry.add('mail_mailcow_mailbox_tree', MailboxesListView);
diff --git a/bemade_mailcow_blacklist/static/src/js/mailcow_alias.js b/bemade_mailcow_blacklist/static/src/js/mailcow_alias.js
deleted file mode 100644
index 40f9cce..0000000
--- a/bemade_mailcow_blacklist/static/src/js/mailcow_alias.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @odoo-module **/
-
-import ListController from 'web.ListController';
-import ListView from 'web.ListView';
-const viewRegistry = require('web.view_registry');
-
-const AliasesListController = ListController.extend({
- // buttons_template must match the t-name on the template for the button (static xml)
- buttons_template: 'mail.mailcow_aliases_list_view_buttons',
- events: _.extend({}, ListController.prototype.events, {
- 'click .o_button_sync_aliases': '_onSyncAliases',
- }),
- // This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
- _onSyncAliases: function () {
- this._rpc({
- model: 'mail.mailcow.alias',
- method: 'sync_aliases',
- args: [],
- });
- // Couldn't test this for real, but it runs the action. May need a this.reload()
- },
-});
-
-const AliasesListView = ListView.extend({
- config: _.extend({}, ListView.prototype.config, {
- Controller: AliasesListController,
- }),
-});
-
-// key must match with the js_class attribute of the tree view you want to modify
-viewRegistry.add('mail_mailcow_aliases_tree', AliasesListView);
diff --git a/bemade_mailcow_blacklist/static/src/js/mailcow_blacklist.js b/bemade_mailcow_blacklist/static/src/js/mailcow_blacklist.js
deleted file mode 100644
index 41186c9..0000000
--- a/bemade_mailcow_blacklist/static/src/js/mailcow_blacklist.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @odoo-module **/
-
-import ListController from 'web.ListController';
-import ListView from 'web.ListView';
-const viewRegistry = require('web.view_registry');
-
-const MailboxesListController = ListController.extend({
- // buttons_template must match the t-name on the template for the button (static xml)
- buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
- events: _.extend({}, ListController.prototype.events, {
- 'click .o_button_sync_mailboxes': '_onSyncMailboxes',
- }),
- // This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
- _onSyncMailboxes: function () {
- this._rpc({
- model: 'mail.mailcow.mailbox',
- method: 'sync_mailboxes',
- args: [],
- });
- // Couldn't test this for real, but it runs the action. May need a this.reload()
- },
-});
-
-const MailboxesListView = ListView.extend({
- config: _.extend({}, ListView.prototype.config, {
- Controller: MailboxesListController,
- }),
-});
-
-// key must match with the js_class attribute of the tree view you want to modify
-viewRegistry.add('mail_mailcow_mailbox_tree', MailboxesListView);
diff --git a/bemade_mailcow_blacklist/static/src/js/mailcow_mailbox.js b/bemade_mailcow_blacklist/static/src/js/mailcow_mailbox.js
deleted file mode 100644
index 41186c9..0000000
--- a/bemade_mailcow_blacklist/static/src/js/mailcow_mailbox.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/** @odoo-module **/
-
-import ListController from 'web.ListController';
-import ListView from 'web.ListView';
-const viewRegistry = require('web.view_registry');
-
-const MailboxesListController = ListController.extend({
- // buttons_template must match the t-name on the template for the button (static xml)
- buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
- events: _.extend({}, ListController.prototype.events, {
- 'click .o_button_sync_mailboxes': '_onSyncMailboxes',
- }),
- // This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
- _onSyncMailboxes: function () {
- this._rpc({
- model: 'mail.mailcow.mailbox',
- method: 'sync_mailboxes',
- args: [],
- });
- // Couldn't test this for real, but it runs the action. May need a this.reload()
- },
-});
-
-const MailboxesListView = ListView.extend({
- config: _.extend({}, ListView.prototype.config, {
- Controller: MailboxesListController,
- }),
-});
-
-// key must match with the js_class attribute of the tree view you want to modify
-viewRegistry.add('mail_mailcow_mailbox_tree', MailboxesListView);
diff --git a/bemade_mailcow_blacklist/static/src/xml/mailcow_alias.xml b/bemade_mailcow_blacklist/static/src/xml/mailcow_alias.xml
deleted file mode 100644
index 579bcb4..0000000
--- a/bemade_mailcow_blacklist/static/src/xml/mailcow_alias.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/bemade_mailcow_blacklist/static/src/xml/mailcow_blacklist.xml b/bemade_mailcow_blacklist/static/src/xml/mailcow_blacklist.xml
deleted file mode 100644
index 48e1b06..0000000
--- a/bemade_mailcow_blacklist/static/src/xml/mailcow_blacklist.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/bemade_mailcow_blacklist/static/src/xml/mailcow_mailbox.xml b/bemade_mailcow_blacklist/static/src/xml/mailcow_mailbox.xml
deleted file mode 100644
index e179359..0000000
--- a/bemade_mailcow_blacklist/static/src/xml/mailcow_mailbox.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/bemade_mailcow_blacklist/static/src/xml/mailcow_templates.xml b/bemade_mailcow_blacklist/static/src/xml/mailcow_templates.xml
new file mode 100644
index 0000000..80e19b0
--- /dev/null
+++ b/bemade_mailcow_blacklist/static/src/xml/mailcow_templates.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bemade_mailcow_blacklist/views/mailcow_alias_views.xml b/bemade_mailcow_blacklist/views/mailcow_alias_views.xml
index 457168d..367c6d2 100644
--- a/bemade_mailcow_blacklist/views/mailcow_alias_views.xml
+++ b/bemade_mailcow_blacklist/views/mailcow_alias_views.xml
@@ -4,11 +4,14 @@
mailcow.alias.view.treemail.mailcow.alias
-
-
+
-
+
+
+
+
+
diff --git a/bemade_mailcow_blacklist/views/mailcow_blacklist_views.xml b/bemade_mailcow_blacklist/views/mailcow_blacklist_views.xml
index 9c09a78..fe51427 100644
--- a/bemade_mailcow_blacklist/views/mailcow_blacklist_views.xml
+++ b/bemade_mailcow_blacklist/views/mailcow_blacklist_views.xml
@@ -4,7 +4,7 @@
mailcow.blacklist.view.treemail.mailcow.blacklist
-
+
@@ -61,6 +61,6 @@
tree
-
+
diff --git a/bemade_mailcow_blacklist/views/mailcow_mailbox_views.xml b/bemade_mailcow_blacklist/views/mailcow_mailbox_views.xml
index 797c6ac..cef6200 100644
--- a/bemade_mailcow_blacklist/views/mailcow_mailbox_views.xml
+++ b/bemade_mailcow_blacklist/views/mailcow_mailbox_views.xml
@@ -4,13 +4,13 @@
mailcow.mailbox.view.treemail.mailcow.mailbox
-
-
+
+