From 83dc8d346ef1a0db498a6233f76a1d53af5ea5a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20V=C3=A9zina?=
Date: Sun, 2 Jul 2023 15:07:33 -0400
Subject: [PATCH] 2 more modules to test
---
bemade_helpdesk_mailcow_blacklist/__init__.py | 1 +
.../__manifest__.py | 36 +++++++++++++++++++
.../data/helpdesk_stages.xml | 10 ++++++
.../demo/demo.xml | 27 ++++++++++++++
.../models/__init__.py | 1 +
.../models/helpdesk_ticket.py | 24 +++++++++++++
.../models/res_partner.py | 11 ++++++
.../security/ir.model.access.csv | 2 ++
.../views/helpdesk_ticket_views.xml | 13 +++++++
bemade_mailcow_blacklist/__manifest__.py | 27 +++++++-------
.../controllers/controllers.py | 13 +++++++
.../__manifest__.py | 32 +++++++++++++++++
.../controllers/controllers.py | 12 +++++++
.../data/mail_template_data.xml | 34 ++++++++++++++++++
.../models/mail_mail.py | 16 +++++++++
.../models/res_partner.py | 30 ++++++++++++++++
.../security/ir.model.access.csv | 2 ++
.../views/res_partner_views.xml | 36 +++++++++++++++++++
18 files changed, 313 insertions(+), 14 deletions(-)
create mode 100644 bemade_helpdesk_mailcow_blacklist/__init__.py
create mode 100644 bemade_helpdesk_mailcow_blacklist/__manifest__.py
create mode 100644 bemade_helpdesk_mailcow_blacklist/data/helpdesk_stages.xml
create mode 100644 bemade_helpdesk_mailcow_blacklist/demo/demo.xml
create mode 100644 bemade_helpdesk_mailcow_blacklist/models/__init__.py
create mode 100644 bemade_helpdesk_mailcow_blacklist/models/helpdesk_ticket.py
create mode 100644 bemade_helpdesk_mailcow_blacklist/models/res_partner.py
create mode 100644 bemade_helpdesk_mailcow_blacklist/security/ir.model.access.csv
create mode 100644 bemade_helpdesk_mailcow_blacklist/views/helpdesk_ticket_views.xml
create mode 100644 bemade_mailcow_blacklist/controllers/controllers.py
create mode 100644 bemade_partner_email_validation/__manifest__.py
create mode 100644 bemade_partner_email_validation/controllers/controllers.py
create mode 100644 bemade_partner_email_validation/data/mail_template_data.xml
create mode 100644 bemade_partner_email_validation/models/mail_mail.py
create mode 100644 bemade_partner_email_validation/models/res_partner.py
create mode 100644 bemade_partner_email_validation/security/ir.model.access.csv
create mode 100644 bemade_partner_email_validation/views/res_partner_views.xml
diff --git a/bemade_helpdesk_mailcow_blacklist/__init__.py b/bemade_helpdesk_mailcow_blacklist/__init__.py
new file mode 100644
index 0000000..0650744
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/bemade_helpdesk_mailcow_blacklist/__manifest__.py b/bemade_helpdesk_mailcow_blacklist/__manifest__.py
new file mode 100644
index 0000000..72bdabf
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/__manifest__.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+{
+ 'name': 'Helpdesk Mailcow Blacklist',
+ 'version': '1.0.0',
+ 'category': 'Administration',
+ 'summary': 'Module for adding blacklist functionality to the helpdesk.',
+ 'description': """
+ Helpdesk Mailcow Blacklist
+ ==========================
+
+ This module extends the functionality of the Helpdesk and Mailcow Blacklist modules by adding an action to blacklist the sender of a Helpdesk ticket.
+
+ Main Features:
+ --------------
+ - Adds a button on Helpdesk tickets to blacklist the email sender.
+ - This button is only visible when an email is associated with the ticket.
+ - Blacklisting an email sender automatically moves the Helpdesk ticket to a new 'Spam' stage, which is marked as closed.
+ - The 'Spam' stage is automatically created by this module.
+ """,
+ 'sequence': 10,
+ 'license': 'GPL-3',
+ 'author': 'Bemade',
+ 'website': 'https://www.bemade.org',
+ 'depends': ['helpdesk', 'bemade_mailcow_blacklist'],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'data/helpdesk_stages.xml',
+ 'views/helpdesk_ticket_views.xml',
+ ],
+ 'demo': [
+ 'demo/demo.xml'
+ ],
+ 'installable': True,
+ 'application': False,
+ 'auto_install': False
+}
diff --git a/bemade_helpdesk_mailcow_blacklist/data/helpdesk_stages.xml b/bemade_helpdesk_mailcow_blacklist/data/helpdesk_stages.xml
new file mode 100644
index 0000000..3656b40
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/data/helpdesk_stages.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ Spam
+ 50
+ True
+
+
+
diff --git a/bemade_helpdesk_mailcow_blacklist/demo/demo.xml b/bemade_helpdesk_mailcow_blacklist/demo/demo.xml
new file mode 100644
index 0000000..b8f2a97
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/demo/demo.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+ Demo User
+ demo_user
+ demo_user
+ demo_user@example.com
+
+
+
+
+ Demo Helpdesk Team
+
+
+
+
+ Demo Helpdesk Ticket
+
+
+ demo_sender@example.com
+
+ This is a demo ticket for testing the blacklist feature.
+
+
+
diff --git a/bemade_helpdesk_mailcow_blacklist/models/__init__.py b/bemade_helpdesk_mailcow_blacklist/models/__init__.py
new file mode 100644
index 0000000..deff245
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/models/__init__.py
@@ -0,0 +1 @@
+from . import helpdesk_ticket
\ No newline at end of file
diff --git a/bemade_helpdesk_mailcow_blacklist/models/helpdesk_ticket.py b/bemade_helpdesk_mailcow_blacklist/models/helpdesk_ticket.py
new file mode 100644
index 0000000..5ca307f
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/models/helpdesk_ticket.py
@@ -0,0 +1,24 @@
+from odoo import api, fields, models
+from odoo.exceptions import UserError
+
+
+class HelpdeskTicket(models.Model):
+ _inherit = 'helpdesk.ticket'
+
+ def add_blacklist(self):
+ self.ensure_one()
+
+ # Create a new blacklist record
+ blacklist = self.env['mailcow.blacklist'].create({
+ 'email': self.email,
+ })
+
+ # Assign 'spam' as a closed stage
+ spam_stage = self.env.ref('bemade_helpdesk_mailcow_blacklist.helpdesk_stage_spam')
+
+ if spam_stage:
+ self.stage_id = spam_stage.id
+ else:
+ raise UserError(_('The Spam stage does not exist.'))
+
+ return True
diff --git a/bemade_helpdesk_mailcow_blacklist/models/res_partner.py b/bemade_helpdesk_mailcow_blacklist/models/res_partner.py
new file mode 100644
index 0000000..b11a071
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/models/res_partner.py
@@ -0,0 +1,11 @@
+from odoo import models, api
+
+class ResPartner(models.Model):
+ _inherit = 'res.partner'
+
+ @api.multi
+ def send_validation_email(self):
+ for partner in self:
+ if not partner.email_validated:
+ # Assuming you have a method called send_validation_email that sends the validation email.
+ partner.send_validation_email()
diff --git a/bemade_helpdesk_mailcow_blacklist/security/ir.model.access.csv b/bemade_helpdesk_mailcow_blacklist/security/ir.model.access.csv
new file mode 100644
index 0000000..4d035d4
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_bemade_helpdesk_mailcow_blacklist,access_bemade_helpdesk_mailcow_blacklist,model_bemade_helpdesk_mailcow_blacklist,base.group_user,1,1,1,1
diff --git a/bemade_helpdesk_mailcow_blacklist/views/helpdesk_ticket_views.xml b/bemade_helpdesk_mailcow_blacklist/views/helpdesk_ticket_views.xml
new file mode 100644
index 0000000..fb2fde7
--- /dev/null
+++ b/bemade_helpdesk_mailcow_blacklist/views/helpdesk_ticket_views.xml
@@ -0,0 +1,13 @@
+
+
+
+ helpdesk.ticket.form.mailcow
+ helpdesk.ticket
+
+
+
+
+
+
+
+
diff --git a/bemade_mailcow_blacklist/__manifest__.py b/bemade_mailcow_blacklist/__manifest__.py
index cdb0e36..a076e1a 100644
--- a/bemade_mailcow_blacklist/__manifest__.py
+++ b/bemade_mailcow_blacklist/__manifest__.py
@@ -2,23 +2,23 @@
{
'name': 'Mailcow Integration',
'version': '1.0.0',
- 'category': 'Extra Tools',
+ 'category': 'Administration',
'summary': 'Module for integrating Mailcow email server with Odoo.',
'description': """
-Mailcow Integration
-===================
+ Mailcow Integration
+ ===================
-This module integrates the Mailcow email server with Odoo, providing a seamless email communication solution for your Odoo instance. It allows for syncing of mailboxes and email aliases from Mailcow to Odoo and vice versa.
+ This module integrates the Mailcow email server with Odoo, providing a seamless email communication solution for your Odoo instance. It allows for syncing of mailboxes and email aliases from Mailcow to Odoo and vice versa.
-Main Features:
---------------
-* Synchronize Mailcow mailboxes with Odoo users.
-* Synchronize Mailcow email aliases with Odoo.
-* Configuration of Mailcow API credentials in Odoo settings.
-* Automatically create and manage mailboxes and aliases in Mailcow when they are created in Odoo.
-""",
+ Main Features:
+ --------------
+ * Synchronize Mailcow mailboxes with Odoo users.
+ * Synchronize Mailcow email aliases with Odoo.
+ * Configuration of Mailcow API credentials in Odoo settings.
+ * Automatically create and manage mailboxes and aliases in Mailcow when they are created in Odoo.
+ """,
'sequence': 10,
- 'license': 'OPL-1',
+ 'license': 'GPL-3',
'author': 'Bemade',
'website': 'https://www.bemade.org',
'depends': ['hr', 'mail', 'bemade_user_password_bundle'],
@@ -29,7 +29,6 @@ Main Features:
'views/mailcow_alias_views.xml',
'views/mailcow_blacklist_views.xml',
'views/res_users_views.xml',
-
],
"assets": {
"web.assets_backend": [
@@ -42,5 +41,5 @@ Main Features:
'demo': [],
'installable': True,
'application': False,
- 'auto_install': False,
+ 'auto_install': False
}
diff --git a/bemade_mailcow_blacklist/controllers/controllers.py b/bemade_mailcow_blacklist/controllers/controllers.py
new file mode 100644
index 0000000..bd69c50
--- /dev/null
+++ b/bemade_mailcow_blacklist/controllers/controllers.py
@@ -0,0 +1,13 @@
+from odoo import http
+from odoo.http import request
+
+class EmailValidationController(http.Controller):
+
+ @http.route('/email_validation//', type='http', auth='public', website=True)
+ def email_validation(self, partner_id, token):
+ partner = request.env['res.partner'].sudo().browse(partner_id)
+ if partner and partner.validation_token == token:
+ partner.sudo().write({'email_validated': True})
+ return "Email validated!"
+ else:
+ return "Invalid validation link."
diff --git a/bemade_partner_email_validation/__manifest__.py b/bemade_partner_email_validation/__manifest__.py
new file mode 100644
index 0000000..032e2e4
--- /dev/null
+++ b/bemade_partner_email_validation/__manifest__.py
@@ -0,0 +1,32 @@
+{
+ 'name': 'Validate Partner Email',
+ 'version': '1.0.0',
+ 'category': 'Extra Tools',
+ 'summary': 'Module to validate the email addresses of partners.',
+ 'description': """
+ Validate Partner Email
+ ===================
+
+ This module adds a functionality to validate the email addresses of partners in Odoo. A new boolean field 'email_validated' is added to the 'res.partner' model. When an email address is entered or changed, 'email_validated' is set to False and a validation email is sent to the new email address. If the recipient clicks the link in the validation email, 'email_validated' is set to True. Before sending an email to a partner, the system checks whether the partner's email is validated and if not, a message is posted in the chatter.
+
+ Main Features:
+ --------------
+ * Add 'email_validated' field to 'res.partner'.
+ * Send validation email when 'email_validated' is False.
+ * Post message in chatter when trying to send email to partner with unvalidated email.
+ """,
+ 'sequence': 10,
+ 'license': 'GPL-3',
+ 'author': 'Bemade',
+ 'website': 'https://www.bemade.org',
+ 'depends': ['base', 'mail'],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'views/res_partner_views.xml',
+ 'data/mail_template_data.xml'
+ ],
+ 'demo': ['demo/res_partner_demo.xml'],
+ 'installable': True,
+ 'application': False,
+ 'auto_install': False
+}
\ No newline at end of file
diff --git a/bemade_partner_email_validation/controllers/controllers.py b/bemade_partner_email_validation/controllers/controllers.py
new file mode 100644
index 0000000..e502460
--- /dev/null
+++ b/bemade_partner_email_validation/controllers/controllers.py
@@ -0,0 +1,12 @@
+from odoo import http
+from odoo.http import request
+
+class ValidateEmailController(http.Controller):
+
+ @http.route(['/validate_email//'], type='http', auth="public", website=True)
+ def validate_email(self, partner, token, **kw):
+ if partner.email_validation_token != token:
+ return request.render("bemade_validate_partner_email.invalid_token", {})
+ else:
+ partner.sudo().write({'email_validated': True})
+ return request.render("bemade_validate_partner_email.email_validated", {})
diff --git a/bemade_partner_email_validation/data/mail_template_data.xml b/bemade_partner_email_validation/data/mail_template_data.xml
new file mode 100644
index 0000000..20eb1fb
--- /dev/null
+++ b/bemade_partner_email_validation/data/mail_template_data.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ Email Validation
+
+ Please validate your email address
+
+ Dear ${object.name},
+
+ We have recently received a request to validate your email address
+ for our records. Please click on the link below to confirm that
+ this is your email address.
+