From e4bd01b221755c6690fd6d539ef10d98a5691a2d Mon Sep 17 00:00:00 2001 From: clementmbr Date: Thu, 9 Jul 2020 19:57:32 -0300 Subject: [PATCH 01/16] [REF] Rename module `file_email` and basic migration to v12 --- attachment_queue_email/README.rst | 82 ++++ attachment_queue_email/__init__.py | 1 + attachment_queue_email/__manifest__.py | 18 + attachment_queue_email/models/__init__.py | 2 + .../models/attachment_queue.py | 83 ++++ attachment_queue_email/models/fetchmail.py | 54 +++ .../readme/CONTRIBUTORS.rst | 3 + attachment_queue_email/readme/DESCRIPTION.rst | 1 + attachment_queue_email/readme/USAGE.rst | 3 + .../security/ir.model.access.csv | 3 + .../static/description/index.html | 427 ++++++++++++++++++ .../views/fetchmail_view.xml | 58 +++ 12 files changed, 735 insertions(+) create mode 100644 attachment_queue_email/README.rst create mode 100644 attachment_queue_email/__init__.py create mode 100644 attachment_queue_email/__manifest__.py create mode 100644 attachment_queue_email/models/__init__.py create mode 100644 attachment_queue_email/models/attachment_queue.py create mode 100644 attachment_queue_email/models/fetchmail.py create mode 100644 attachment_queue_email/readme/CONTRIBUTORS.rst create mode 100644 attachment_queue_email/readme/DESCRIPTION.rst create mode 100644 attachment_queue_email/readme/USAGE.rst create mode 100644 attachment_queue_email/security/ir.model.access.csv create mode 100644 attachment_queue_email/static/description/index.html create mode 100644 attachment_queue_email/views/fetchmail_view.xml diff --git a/attachment_queue_email/README.rst b/attachment_queue_email/README.rst new file mode 100644 index 00000000000..ac1baab70f1 --- /dev/null +++ b/attachment_queue_email/README.rst @@ -0,0 +1,82 @@ +========== +File Email +========== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/12.0/attachment_queue_email + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-attachment_queue_email + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Abstract module for importing and processing the attachment of an email. The attachment of the email will be imported as an ir.attachment.metadata and then in your custom module you can process it. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go the menu Settings > File Exchange > Configuration + +A implementation must be defined in your own module to test this module on a use case + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Valentin CHEMIERE +* Florian DA COSTA +* Sebastien BEAU + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/attachment_queue_email/__init__.py b/attachment_queue_email/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/attachment_queue_email/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/attachment_queue_email/__manifest__.py b/attachment_queue_email/__manifest__.py new file mode 100644 index 00000000000..673e2cbc3fd --- /dev/null +++ b/attachment_queue_email/__manifest__.py @@ -0,0 +1,18 @@ +# @author Sébastien BEAU @ Akretion +# @author Florian DA COSTA @ Akretion +# @author Benoit GUILLOT @ Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "File Email", + "version": "12.0.1.0.0", + "author": "Akretion,Odoo Community Association (OCA)", + "category": "Generic Modules", + "license": "AGPL-3", + "website": "http://www.akretion.com/", + "depends": ["attachment_queue", "fetchmail"], + "data": ["security/ir.model.access.csv", "views/fetchmail_view.xml"], + "demo": [], + "installable": True, + "images": [], +} diff --git a/attachment_queue_email/models/__init__.py b/attachment_queue_email/models/__init__.py new file mode 100644 index 00000000000..ea9e3915ab1 --- /dev/null +++ b/attachment_queue_email/models/__init__.py @@ -0,0 +1,2 @@ +from . import attachment_queue +from . import fetchmail diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py new file mode 100644 index 00000000000..700cfa2e7c4 --- /dev/null +++ b/attachment_queue_email/models/attachment_queue.py @@ -0,0 +1,83 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields, api +import base64 + + +class AttachmentQueue(models.Model): + _inherit = "attachment.queue" + + fetchmail_attachment_condition_id = fields.Many2one( + "fetchmail.attachment.condition", + string="FetchMail condition", + help="The Fetchmail attachment condition used to create this attachment", + ) + fetchmail_server_id = fields.Many2one( + "fetchmail.server", + string="Email Server", + related="fetchmail_attachment_condition_id.server_id", + store=True, + readonly=True, + help="The email server used to create this attachment", + ) + + @api.model + def _get_attachment_metadata_data(self, condition, msg, att): + values = { + "fetchmail_attachment_condition_id": condition.id, + "file_type": condition.file_type, + "name": msg["subject"], + "sync_date": msg["date"], + "datas_fname": att[0], + "datas": base64.b64encode(att[1]), + "state": "pending", + } + return values + + @api.model + def prepare_data_from_basic_condition(self, condition, msg): + vals_list = [] + if ( + condition.from_email in msg["from"] + and condition.mail_subject in msg["subject"] + ): + for att in msg["attachments"]: + if condition.file_extension in att[0]: + vals_list.append( + self._get_attachment_metadata_data(condition, msg, att) + ) + return vals_list + + @api.model + def _prepare_data_for_attachment_metadata(self, msg): + """Method to prepare the data for creating a attachment metadata. + :param msg: a dictionnary with the email data + :type: dict + + :return: a list of dictionnary that contains the attachment metadata data + :rtype: list + """ + res = [] + server_id = self.env.context.get("default_fetchmail_server_id", False) + file_condition_obj = self.env["fetchmail.attachment.condition"] + conds = file_condition_obj.search([("server_id", "=", server_id)]) + for cond in conds: + vals_list = self.prepare_data_from_basic_condition(cond, msg) + if vals_list: + res += vals_list + return res + + @api.model + def message_new(self, msg, custom_values): + created_recs = [] + res = self._prepare_data_for_attachment_metadata(msg) + if res: + for vals in res: + default = self.env.context.get("default_attachment_metadata_vals") + if default: + for key in default: + if key not in vals: + vals[key] = default[key] + created_recs.append(self.create(vals)) + return created_recs[0] + return None diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py new file mode 100644 index 00000000000..721b02feb7b --- /dev/null +++ b/attachment_queue_email/models/fetchmail.py @@ -0,0 +1,54 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields, api + + +class FetchmailServer(models.Model): + _inherit = "fetchmail.server" + + def company_default_get(self): + company_id = self.env["res.company"]._company_default_get("fetchmail.server") + return self.env["res.company"].browse(company_id).id + + company_id = fields.Many2one( + "res.company", string="Company", required=True, default=company_default_get + ) + attachment_metadata_condition_ids = fields.One2many( + "fetchmail.attachment.condition", "server_id", string="Attachment Conditions" + ) + + @api.multi + def get_context_for_server(self): + self.ensure_one() + ctx = self.env.context.copy() + ctx["default_fetchmail_server_id"] = self.id + ctx["default_file_document_vals"] = {} + return ctx + + @api.multi + def fetch_mail(self): + for server in self: + ctx = server.get_context_for_server() + super(FetchmailServer, server.with_context(ctx)).fetch_mail() + return True + + +class FetchmailAttachmentCondition(models.Model): + _name = "fetchmail.attachment.condition" + _description = "Fetchmail Attachment Conditions" + + name = fields.Char(string="Name", required=True,) + from_email = fields.Char(string="Email") + mail_subject = fields.Char() + type = fields.Selection( + selection=[("normal", "Normal")], + required=True, + default="normal", + help="Create your own type if the normal type " + "do not correspond to your need", + ) + file_extension = fields.Char(required=True, help="File extension or file name") + server_id = fields.Many2one("fetchmail.server", string="Server Mail") + file_type = fields.Selection( + selection=[], help="The file type will show some special option" + ) diff --git a/attachment_queue_email/readme/CONTRIBUTORS.rst b/attachment_queue_email/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..a70c9f1728e --- /dev/null +++ b/attachment_queue_email/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Valentin CHEMIERE +* Florian DA COSTA +* Sebastien BEAU diff --git a/attachment_queue_email/readme/DESCRIPTION.rst b/attachment_queue_email/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..6c2f2e3de87 --- /dev/null +++ b/attachment_queue_email/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Abstract module for importing and processing the attachment of an email. The attachment of the email will be imported as an ir.attachment.metadata and then in your custom module you can process it. diff --git a/attachment_queue_email/readme/USAGE.rst b/attachment_queue_email/readme/USAGE.rst new file mode 100644 index 00000000000..d4a163ac066 --- /dev/null +++ b/attachment_queue_email/readme/USAGE.rst @@ -0,0 +1,3 @@ +Go the menu Settings > File Exchange > Configuration + +A implementation must be defined in your own module to test this module on a use case diff --git a/attachment_queue_email/security/ir.model.access.csv b/attachment_queue_email/security/ir.model.access.csv new file mode 100644 index 00000000000..9fff725bf35 --- /dev/null +++ b/attachment_queue_email/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_fetchmail_attachment_condition_manager,fetchmail.attachment.condition.user,model_fetchmail_attachment_condition,base.group_system,1,1,1,1 +access_fetchmail_attachment_condition_user,fetchmail.attachment.condition.user,model_fetchmail_attachment_condition,base.group_user,1,0,0,0 diff --git a/attachment_queue_email/static/description/index.html b/attachment_queue_email/static/description/index.html new file mode 100644 index 00000000000..6a0cb317b87 --- /dev/null +++ b/attachment_queue_email/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +File Email + + + +
+

File Email

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

Abstract module for importing and processing the attachment of an email. The attachment of the email will be imported as an ir.attachment.metadata and then in your custom module you can process it.

+

Table of contents

+ +
+

Usage

+

Go the menu Settings > File Exchange > Configuration

+

A implementation must be defined in your own module to test this module on a use case

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/attachment_queue_email/views/fetchmail_view.xml b/attachment_queue_email/views/fetchmail_view.xml new file mode 100644 index 00000000000..90e6db3f6b3 --- /dev/null +++ b/attachment_queue_email/views/fetchmail_view.xml @@ -0,0 +1,58 @@ + + + + + fetchmail.server + + + + + + + + + + + + + + + + view_fetchmail_attachment_condition_tree + fetchmail.attachment.condition + + + + + + + + + + + + + + view_fetchmail_attachment_condition_form + fetchmail.attachment.condition + +
+ +

+

+ + + + + + + + +
+
+
+
+ +
From 24c702803c4ee9261efbc972f031a60c9a0379d1 Mon Sep 17 00:00:00 2001 From: clementmbr Date: Fri, 10 Jul 2020 15:09:57 -0300 Subject: [PATCH 02/16] [IMP] rename methods, file_extension not required and remove @api.multi --- .../models/attachment_queue.py | 23 ++++++++----- attachment_queue_email/models/fetchmail.py | 34 ++++++++++--------- .../views/fetchmail_view.xml | 22 ++++++------ 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index 700cfa2e7c4..608464f5ba1 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -22,7 +22,7 @@ class AttachmentQueue(models.Model): ) @api.model - def _get_attachment_metadata_data(self, condition, msg, att): + def _get_attachment_queue_data(self, condition, msg, att): values = { "fetchmail_attachment_condition_id": condition.id, "file_type": condition.file_type, @@ -42,19 +42,22 @@ def prepare_data_from_basic_condition(self, condition, msg): and condition.mail_subject in msg["subject"] ): for att in msg["attachments"]: - if condition.file_extension in att[0]: + if condition.file_extension in att[0] or not condition.file_extension: vals_list.append( - self._get_attachment_metadata_data(condition, msg, att) + self._get_attachment_queue_data(condition, msg, att) ) return vals_list @api.model - def _prepare_data_for_attachment_metadata(self, msg): - """Method to prepare the data for creating a attachment metadata. + def _prepare_data_for_attachment_queue(self, msg): + """Prepare the datas for the creation of one or many attachment.queue depending + on the number of the email's attachments files and if the email matches the + fetchmail.attachment.condition's conditions. + :param msg: a dictionnary with the email data :type: dict - :return: a list of dictionnary that contains the attachment metadata data + :return: a list of dictionnary that contains the attachment.queue data :rtype: list """ res = [] @@ -69,11 +72,15 @@ def _prepare_data_for_attachment_metadata(self, msg): @api.model def message_new(self, msg, custom_values): + """Create Attachments Queues objects from the new received email's attachments. + """ + # Rewriting completely ``message_new`` instead of overiding it in order to + # allows the creation of many new objects instead of only one. created_recs = [] - res = self._prepare_data_for_attachment_metadata(msg) + res = self._prepare_data_for_attachment_queue(msg) if res: for vals in res: - default = self.env.context.get("default_attachment_metadata_vals") + default = self.env.context.get("default_attachment_queue_vals") if default: for key in default: if key not in vals: diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index 721b02feb7b..44be8ff3428 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -13,19 +13,21 @@ def company_default_get(self): company_id = fields.Many2one( "res.company", string="Company", required=True, default=company_default_get ) - attachment_metadata_condition_ids = fields.One2many( - "fetchmail.attachment.condition", "server_id", string="Attachment Conditions" + attachment_queue_condition_ids = fields.One2many( + "fetchmail.attachment.condition", + "server_id", + string="Attachment Conditions", + help="Files attached to the emails matching these conditions will be imported " + "in Odoo as 'Attachment Queue' objects", ) - @api.multi def get_context_for_server(self): self.ensure_one() ctx = self.env.context.copy() ctx["default_fetchmail_server_id"] = self.id - ctx["default_file_document_vals"] = {} + ctx["default_attachment_queue_vals"] = {} return ctx - @api.multi def fetch_mail(self): for server in self: ctx = server.get_context_for_server() @@ -37,18 +39,18 @@ class FetchmailAttachmentCondition(models.Model): _name = "fetchmail.attachment.condition" _description = "Fetchmail Attachment Conditions" - name = fields.Char(string="Name", required=True,) - from_email = fields.Char(string="Email") - mail_subject = fields.Char() - type = fields.Selection( - selection=[("normal", "Normal")], - required=True, - default="normal", - help="Create your own type if the normal type " - "do not correspond to your need", + name = fields.Char(string="Condition Name", required=True,) + email_from = fields.Char(string="Email From") + email_subject = fields.Char(string="Email Subject") + file_extension = fields.Char( + string="File Extension", + help="The extension (or part of the name) of the sought files. " + "If empty, all the email's attachments will be imported.", ) - file_extension = fields.Char(required=True, help="File extension or file name") server_id = fields.Many2one("fetchmail.server", string="Server Mail") file_type = fields.Selection( - selection=[], help="The file type will show some special option" + selection=[], + help="The 'file type' is transmited to the 'Attachment Queue' objects created " + "from the selected emails attachments. It will allow Odoo to recognize " + "what do do with them once created.", ) diff --git a/attachment_queue_email/views/fetchmail_view.xml b/attachment_queue_email/views/fetchmail_view.xml index 90e6db3f6b3..28bf754bcc5 100644 --- a/attachment_queue_email/views/fetchmail_view.xml +++ b/attachment_queue_email/views/fetchmail_view.xml @@ -10,7 +10,7 @@ - + @@ -23,11 +23,10 @@ - - - + + - + @@ -40,15 +39,14 @@

- - - - - - + + + + +
From 3eb47d43fc939521c74c20a711696b96e63ad9df Mon Sep 17 00:00:00 2001 From: clementmbr Date: Fri, 10 Jul 2020 17:09:11 -0300 Subject: [PATCH 03/16] [IMP] fetchmail_views --- attachment_queue_email/__manifest__.py | 2 +- attachment_queue_email/models/fetchmail.py | 4 ++-- ...fetchmail_view.xml => fetchmail_views.xml} | 20 +++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) rename attachment_queue_email/views/{fetchmail_view.xml => fetchmail_views.xml} (80%) diff --git a/attachment_queue_email/__manifest__.py b/attachment_queue_email/__manifest__.py index 673e2cbc3fd..7aa87e9ef1e 100644 --- a/attachment_queue_email/__manifest__.py +++ b/attachment_queue_email/__manifest__.py @@ -11,8 +11,8 @@ "license": "AGPL-3", "website": "http://www.akretion.com/", "depends": ["attachment_queue", "fetchmail"], - "data": ["security/ir.model.access.csv", "views/fetchmail_view.xml"], "demo": [], + "data": ["security/ir.model.access.csv", "views/fetchmail_views.xml"], "installable": True, "images": [], } diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index 44be8ff3428..367aa9f5ff2 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -16,7 +16,7 @@ def company_default_get(self): attachment_queue_condition_ids = fields.One2many( "fetchmail.attachment.condition", "server_id", - string="Attachment Conditions", + string="Attachment Condition", help="Files attached to the emails matching these conditions will be imported " "in Odoo as 'Attachment Queue' objects", ) @@ -51,6 +51,6 @@ class FetchmailAttachmentCondition(models.Model): file_type = fields.Selection( selection=[], help="The 'file type' is transmited to the 'Attachment Queue' objects created " - "from the selected emails attachments. It will allow Odoo to recognize " + "from the selected emails attachments.\nIt will allow Odoo to recognize " "what do do with them once created.", ) diff --git a/attachment_queue_email/views/fetchmail_view.xml b/attachment_queue_email/views/fetchmail_views.xml similarity index 80% rename from attachment_queue_email/views/fetchmail_view.xml rename to attachment_queue_email/views/fetchmail_views.xml index 28bf754bcc5..d0f7254bfe0 100644 --- a/attachment_queue_email/views/fetchmail_view.xml +++ b/attachment_queue_email/views/fetchmail_views.xml @@ -21,7 +21,7 @@ view_fetchmail_attachment_condition_tree fetchmail.attachment.condition - + @@ -35,18 +35,22 @@ view_fetchmail_attachment_condition_form fetchmail.attachment.condition -
+ -

-

- +
+
+ - + + +
From 5b754f041708626109bafde98d1c80201c08e5c0 Mon Sep 17 00:00:00 2001 From: clementmbr Date: Fri, 10 Jul 2020 17:09:56 -0300 Subject: [PATCH 04/16] [IMP] add onchange_attachment_condition --- attachment_queue_email/models/fetchmail.py | 11 ++++++++++- attachment_queue_email/views/fetchmail_views.xml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index 367aa9f5ff2..b83a54846d6 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -13,7 +13,7 @@ def company_default_get(self): company_id = fields.Many2one( "res.company", string="Company", required=True, default=company_default_get ) - attachment_queue_condition_ids = fields.One2many( + attachment_condition_ids = fields.One2many( "fetchmail.attachment.condition", "server_id", string="Attachment Condition", @@ -21,6 +21,15 @@ def company_default_get(self): "in Odoo as 'Attachment Queue' objects", ) + @api.onchange("attachment_condition_ids") + def onchange_attachment_condition(self): + for server in self: + if server.attachment_condition_ids: + server.object_id = self.env["ir.model"].search( + [("model", "=", "attachment.queue")] + ) + server.attach = True + def get_context_for_server(self): self.ensure_one() ctx = self.env.context.copy() diff --git a/attachment_queue_email/views/fetchmail_views.xml b/attachment_queue_email/views/fetchmail_views.xml index d0f7254bfe0..d492dbfa6a1 100644 --- a/attachment_queue_email/views/fetchmail_views.xml +++ b/attachment_queue_email/views/fetchmail_views.xml @@ -10,7 +10,7 @@
- +
From 05dfa1646df6f346f7ed4ce8ad5150e44ba4e222 Mon Sep 17 00:00:00 2001 From: clementmbr Date: Mon, 13 Jul 2020 18:03:17 -0300 Subject: [PATCH 05/16] [IMP] add tests --- .../models/attachment_queue.py | 25 +++---- attachment_queue_email/tests/__init__.py | 3 + .../tests/test_attachment_queue_email.py | 75 +++++++++++++++++++ 3 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 attachment_queue_email/tests/__init__.py create mode 100644 attachment_queue_email/tests/test_attachment_queue_email.py diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index 608464f5ba1..e7fc3cfca05 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -26,26 +26,23 @@ def _get_attachment_queue_data(self, condition, msg, att): values = { "fetchmail_attachment_condition_id": condition.id, "file_type": condition.file_type, - "name": msg["subject"], - "sync_date": msg["date"], - "datas_fname": att[0], - "datas": base64.b64encode(att[1]), + "name": msg.get("subject", att.fname), + "sync_date": msg.get("date"), + "datas_fname": att.fname, + "datas": base64.b64encode(att.content), "state": "pending", } return values @api.model - def prepare_data_from_basic_condition(self, condition, msg): + def prepare_data_from_basic_condition(self, cond, msg): vals_list = [] - if ( - condition.from_email in msg["from"] - and condition.mail_subject in msg["subject"] - ): + if str(cond.email_from) in msg.get("from", "") or str( + cond.email_subject + ) in msg.get("subject", ""): for att in msg["attachments"]: - if condition.file_extension in att[0] or not condition.file_extension: - vals_list.append( - self._get_attachment_queue_data(condition, msg, att) - ) + if cond.file_extension in att.fname or not cond.file_extension: + vals_list.append(self._get_attachment_queue_data(cond, msg, att)) return vals_list @api.model @@ -61,7 +58,7 @@ def _prepare_data_for_attachment_queue(self, msg): :rtype: list """ res = [] - server_id = self.env.context.get("default_fetchmail_server_id", False) + server_id = self.env.context.get("fetchmail_server_id", False) file_condition_obj = self.env["fetchmail.attachment.condition"] conds = file_condition_obj.search([("server_id", "=", server_id)]) for cond in conds: diff --git a/attachment_queue_email/tests/__init__.py b/attachment_queue_email/tests/__init__.py new file mode 100644 index 00000000000..c866d7f469f --- /dev/null +++ b/attachment_queue_email/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_attachment_queue_email diff --git a/attachment_queue_email/tests/test_attachment_queue_email.py b/attachment_queue_email/tests/test_attachment_queue_email.py new file mode 100644 index 00000000000..16b3368ab54 --- /dev/null +++ b/attachment_queue_email/tests/test_attachment_queue_email.py @@ -0,0 +1,75 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.test_mail.tests.test_mail_gateway import TestMailgateway +from odoo.addons.test_mail.data.test_mail_data import ( + MAIL_MULTIPART_IMAGE, + MAIL_SINGLE_BINARY, +) + + +class TestAttachmentQueueEmail(TestMailgateway): + def setUp(self): + super().setUp() + self.attach_condition_1 = self.env["fetchmail.attachment.condition"].create( + { + "name": "Attchment Condition 1", + "email_from": "Bruce Wayne", + "file_extension": ".pdf", + } + ) + self.attach_condition_2 = self.env["fetchmail.attachment.condition"].create( + { + "name": "Attchment Condition 2", + "email_subject": "Wonderful pictures", + "file_extension": ".gif", + } + ) + + self.attach_queue_model = self.env["ir.model"].search( + [("model", "=", "attachment.queue")] + ) + self.fetchmail_server = self.env["fetchmail.server"].create( + { + "name": "Test Fetchmail Server 1", + "type": "imap", + "attach": True, + "object_id": self.attach_queue_model.id, + "attachment_condition_ids": [ + (6, 0, [self.attach_condition_1.id, self.attach_condition_2.id]) + ], + } + ) + self.context_server = { + "fetchmail_server_id": self.fetchmail_server.id, + "server_type": self.fetchmail_server.type, + } + + def test_message_single_binary(self): + """Run message_process on emails with attachment check if an attachment_queue + is created + """ + self.assertFalse( + self.env["attachment.queue"].search([("datas_fname", "=", "thetruth.pdf")]) + ) + + self.env["mail.thread"].with_context(self.context_server).message_process( + self.fetchmail_server.object_id.model, MAIL_SINGLE_BINARY, + ) + + attach_queue = self.env["attachment.queue"].search( + [("datas_fname", "=", "thetruth.pdf")] + ) + self.assertEqual(len(attach_queue), 1) + self.assertEqual(attach_queue.datas, b"SSBhbSB0aGUgQmF0TWFuCg==") + + def test_message_multi_image(self): + mail = MAIL_MULTIPART_IMAGE.format(subject="Wonderful pictures", to="") + + self.env["mail.thread"].with_context(self.context_server).message_process( + self.fetchmail_server.object_id.model, mail, + ) + attach_queues = self.env["attachment.queue"].search( + [("datas_fname", "like", ".gif")] + ) + self.assertEqual(len(attach_queues), 3) + self.assertEqual(attach_queues[0].datas_fname, "orangée.gif") From 5644e439a0c879131fade322449d9d89f0dd04a3 Mon Sep 17 00:00:00 2001 From: clementmbr Date: Mon, 13 Jul 2020 18:03:39 -0300 Subject: [PATCH 06/16] [FIX] Remove default_attachment_queue_vals and default_fetchmail_server_id --- attachment_queue_email/models/attachment_queue.py | 5 ----- attachment_queue_email/models/fetchmail.py | 13 ------------- 2 files changed, 18 deletions(-) diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index e7fc3cfca05..0d9cb954656 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -77,11 +77,6 @@ def message_new(self, msg, custom_values): res = self._prepare_data_for_attachment_queue(msg) if res: for vals in res: - default = self.env.context.get("default_attachment_queue_vals") - if default: - for key in default: - if key not in vals: - vals[key] = default[key] created_recs.append(self.create(vals)) return created_recs[0] return None diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index b83a54846d6..f63d6581fec 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -30,19 +30,6 @@ def onchange_attachment_condition(self): ) server.attach = True - def get_context_for_server(self): - self.ensure_one() - ctx = self.env.context.copy() - ctx["default_fetchmail_server_id"] = self.id - ctx["default_attachment_queue_vals"] = {} - return ctx - - def fetch_mail(self): - for server in self: - ctx = server.get_context_for_server() - super(FetchmailServer, server.with_context(ctx)).fetch_mail() - return True - class FetchmailAttachmentCondition(models.Model): _name = "fetchmail.attachment.condition" From e6d85a5aed4029fbe13c3b69700abdde67bd250f Mon Sep 17 00:00:00 2001 From: clementmbr Date: Wed, 15 Jul 2020 09:35:14 -0300 Subject: [PATCH 07/16] [UPD] update Readme --- attachment_queue_email/README.rst | 11 ++++++++--- attachment_queue_email/readme/CONTRIBUTORS.rst | 1 + attachment_queue_email/readme/DESCRIPTION.rst | 4 +++- attachment_queue_email/readme/USAGE.rst | 6 ++++-- attachment_queue_email/static/description/index.html | 10 +++++++--- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/attachment_queue_email/README.rst b/attachment_queue_email/README.rst index ac1baab70f1..c1884f4edcf 100644 --- a/attachment_queue_email/README.rst +++ b/attachment_queue_email/README.rst @@ -25,7 +25,9 @@ File Email |badge1| |badge2| |badge3| |badge4| |badge5| -Abstract module for importing and processing the attachment of an email. The attachment of the email will be imported as an ir.attachment.metadata and then in your custom module you can process it. +Abstract module for importing emails attachments. + +Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. **Table of contents** @@ -35,9 +37,11 @@ Abstract module for importing and processing the attachment of an email. The att Usage ===== -Go the menu Settings > File Exchange > Configuration +Adding an **"Attachment Condition"** to your *Incoming Mail Server* configuration will lead to the creation of ``attachment.queue`` objects from emails attachments coming from this server and matching the given *Attachment Condition*. + + 🔎 Recalling that, as the *Incoming Mail Servers* has only one *"Create a New Record"* field, the emails coming from that server **cannot be used to create other type of objects** than ``attachment.queue``. -A implementation must be defined in your own module to test this module on a use case +Filling the condition's **File Type** field will spread this value to the newly created ``attchment.queue`` objects so they can be processed by a custom module following this **File Type** field value. Bug Tracker =========== @@ -63,6 +67,7 @@ Contributors * Valentin CHEMIERE * Florian DA COSTA * Sebastien BEAU +* Clément Mombereau Maintainers ~~~~~~~~~~~ diff --git a/attachment_queue_email/readme/CONTRIBUTORS.rst b/attachment_queue_email/readme/CONTRIBUTORS.rst index a70c9f1728e..254561ed783 100644 --- a/attachment_queue_email/readme/CONTRIBUTORS.rst +++ b/attachment_queue_email/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Valentin CHEMIERE * Florian DA COSTA * Sebastien BEAU +* Clément Mombereau diff --git a/attachment_queue_email/readme/DESCRIPTION.rst b/attachment_queue_email/readme/DESCRIPTION.rst index 6c2f2e3de87..5567bfeecf2 100644 --- a/attachment_queue_email/readme/DESCRIPTION.rst +++ b/attachment_queue_email/readme/DESCRIPTION.rst @@ -1 +1,3 @@ -Abstract module for importing and processing the attachment of an email. The attachment of the email will be imported as an ir.attachment.metadata and then in your custom module you can process it. +Abstract module for importing emails attachments. + +Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. diff --git a/attachment_queue_email/readme/USAGE.rst b/attachment_queue_email/readme/USAGE.rst index d4a163ac066..41c2a45c2df 100644 --- a/attachment_queue_email/readme/USAGE.rst +++ b/attachment_queue_email/readme/USAGE.rst @@ -1,3 +1,5 @@ -Go the menu Settings > File Exchange > Configuration +Adding an **"Attachment Condition"** to your *Incoming Mail Server* configuration will lead to the creation of ``attachment.queue`` objects from emails attachments coming from this server and matching the given *Attachment Condition*. -A implementation must be defined in your own module to test this module on a use case + 🔎 Recalling that, as the *Incoming Mail Servers* has only one *"Create a New Record"* field, the emails coming from that server **cannot be used to create other type of objects** than ``attachment.queue``. + +Filling the condition's **File Type** field will spread this value to the newly created ``attchment.queue`` objects so they can be processed by a custom module following this **File Type** field value. diff --git a/attachment_queue_email/static/description/index.html b/attachment_queue_email/static/description/index.html index 6a0cb317b87..d367371bd87 100644 --- a/attachment_queue_email/static/description/index.html +++ b/attachment_queue_email/static/description/index.html @@ -368,7 +368,8 @@

File Email

!! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

-

Abstract module for importing and processing the attachment of an email. The attachment of the email will be imported as an ir.attachment.metadata and then in your custom module you can process it.

+

Abstract module for importing emails attachments.

+

Each email’s attachment matching a given “Attachment Condition” will be imported creating a new attachment.queue object. These attachment.queue objects are files wrapped with additional fields (mainly a Filed Type and a State) making them ready to be processed by a custom module as you can read in the attachment_queue documentation.

Table of contents

    @@ -384,8 +385,10 @@

    File Email

Usage

-

Go the menu Settings > File Exchange > Configuration

-

A implementation must be defined in your own module to test this module on a use case

+

Adding an “Attachment Condition” to your Incoming Mail Server configuration will lead to the creation of attachment.queue objects from emails attachments coming from this server and matching the given Attachment Condition.

+
+🔎 Recalling that, as the Incoming Mail Servers has only one “Create a New Record” field, the emails coming from that server cannot be used to create other type of objects than attachment.queue.
+

Filling the condition’s File Type field will spread this value to the newly created attchment.queue objects so they can be processed by a custom module following this File Type field value.

Bug Tracker

@@ -409,6 +412,7 @@

Contributors

  • Valentin CHEMIERE <valentin.chemiere@akretion.com>
  • Florian DA COSTA <florian.dacosta@akretion.com>
  • Sebastien BEAU <sebastian.beau@akretion.com>
  • +
  • Clément Mombereau <clement.mombereau@akretion.com.br>
  • From ac8a2b7e912e90dcc4c65604d870d0dbf7a1bd74 Mon Sep 17 00:00:00 2001 From: clementmbr Date: Fri, 17 Jul 2020 21:24:28 -0300 Subject: [PATCH 08/16] [FIX] Matching condition on email_subject and email_from --- attachment_queue_email/__manifest__.py | 3 ++- attachment_queue_email/models/attachment_queue.py | 10 +++++++--- attachment_queue_email/models/fetchmail.py | 13 +++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/attachment_queue_email/__manifest__.py b/attachment_queue_email/__manifest__.py index 7aa87e9ef1e..bd8263a00f6 100644 --- a/attachment_queue_email/__manifest__.py +++ b/attachment_queue_email/__manifest__.py @@ -10,7 +10,8 @@ "category": "Generic Modules", "license": "AGPL-3", "website": "http://www.akretion.com/", - "depends": ["attachment_queue", "fetchmail"], + "maintainers": ["florian-dacosta", "sebastienbeau", "bealdav"], + "depends": ["attachment_queue", "fetchmail", "test_mail"], "demo": [], "data": ["security/ir.model.access.csv", "views/fetchmail_views.xml"], "installable": True, diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index 0d9cb954656..ed26d2f6bbc 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -37,9 +37,13 @@ def _get_attachment_queue_data(self, condition, msg, att): @api.model def prepare_data_from_basic_condition(self, cond, msg): vals_list = [] - if str(cond.email_from) in msg.get("from", "") or str( - cond.email_subject - ) in msg.get("subject", ""): + # match_from and match_subj are True if empty or if matching with msg's values + match_from = str(cond.email_from) in msg.get("from", "") or not cond.email_from + match_subj = ( + str(cond.email_subject) in msg.get("subject", "") or not cond.email_subject + ) + + if match_from and match_subj: for att in msg["attachments"]: if cond.file_extension in att.fname or not cond.file_extension: vals_list.append(self._get_attachment_queue_data(cond, msg, att)) diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index f63d6581fec..57f29d9a966 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -36,8 +36,17 @@ class FetchmailAttachmentCondition(models.Model): _description = "Fetchmail Attachment Conditions" name = fields.Char(string="Condition Name", required=True,) - email_from = fields.Char(string="Email From") - email_subject = fields.Char(string="Email Subject") + email_from = fields.Char( + string="Email From", + help="If empty, catches the emails from every senders.\n" + "Otherwise catches the emails where the sender's email contains the given " + "characters", + ) + email_subject = fields.Char( + string="Email Subject", + help="If empty, catches the emails with every kind of Subjects.\n" + "Otherwise catches the emails where the Subject contains the given characters", + ) file_extension = fields.Char( string="File Extension", help="The extension (or part of the name) of the sought files. " From 3fc4bcaa03a01b68669131de9d5c643a63d35d21 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Tue, 12 Oct 2021 15:20:37 +0200 Subject: [PATCH 09/16] Migrate attachment_queue_email to v14 --- attachment_queue_email/__manifest__.py | 6 ++--- .../models/attachment_queue.py | 10 ++++---- attachment_queue_email/models/fetchmail.py | 7 ++++-- .../tests/test_attachment_queue_email.py | 22 +++++++++-------- .../views/fetchmail_views.xml | 24 +++++++++++-------- 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/attachment_queue_email/__manifest__.py b/attachment_queue_email/__manifest__.py index bd8263a00f6..f4838c5b9e0 100644 --- a/attachment_queue_email/__manifest__.py +++ b/attachment_queue_email/__manifest__.py @@ -5,13 +5,13 @@ { "name": "File Email", - "version": "12.0.1.0.0", + "version": "14.0.1.0.0", "author": "Akretion,Odoo Community Association (OCA)", "category": "Generic Modules", "license": "AGPL-3", - "website": "http://www.akretion.com/", + "website": "https://github.com/OCA/server-tools", "maintainers": ["florian-dacosta", "sebastienbeau", "bealdav"], - "depends": ["attachment_queue", "fetchmail", "test_mail"], + "depends": ["attachment_queue", "fetchmail"], "demo": [], "data": ["security/ir.model.access.csv", "views/fetchmail_views.xml"], "installable": True, diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index ed26d2f6bbc..86008d16b0d 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -1,8 +1,9 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields, api import base64 +from odoo import api, fields, models + class AttachmentQueue(models.Model): _inherit = "attachment.queue" @@ -26,9 +27,7 @@ def _get_attachment_queue_data(self, condition, msg, att): values = { "fetchmail_attachment_condition_id": condition.id, "file_type": condition.file_type, - "name": msg.get("subject", att.fname), - "sync_date": msg.get("date"), - "datas_fname": att.fname, + "name": att.fname, "datas": base64.b64encode(att.content), "state": "pending", } @@ -73,8 +72,7 @@ def _prepare_data_for_attachment_queue(self, msg): @api.model def message_new(self, msg, custom_values): - """Create Attachments Queues objects from the new received email's attachments. - """ + """Create Attachments Queues objects from the new received email's attachments.""" # Rewriting completely ``message_new`` instead of overiding it in order to # allows the creation of many new objects instead of only one. created_recs = [] diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index 57f29d9a966..cb5c9f2cf5f 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -1,6 +1,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields, api +from odoo import api, fields, models class FetchmailServer(models.Model): @@ -35,7 +35,10 @@ class FetchmailAttachmentCondition(models.Model): _name = "fetchmail.attachment.condition" _description = "Fetchmail Attachment Conditions" - name = fields.Char(string="Condition Name", required=True,) + name = fields.Char( + string="Condition Name", + required=True, + ) email_from = fields.Char( string="Email From", help="If empty, catches the emails from every senders.\n" diff --git a/attachment_queue_email/tests/test_attachment_queue_email.py b/attachment_queue_email/tests/test_attachment_queue_email.py index 16b3368ab54..f31afda0d09 100644 --- a/attachment_queue_email/tests/test_attachment_queue_email.py +++ b/attachment_queue_email/tests/test_attachment_queue_email.py @@ -1,13 +1,13 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo.addons.test_mail.tests.test_mail_gateway import TestMailgateway from odoo.addons.test_mail.data.test_mail_data import ( MAIL_MULTIPART_IMAGE, MAIL_SINGLE_BINARY, ) +from odoo.addons.test_mail.tests.common import TestMailCommon -class TestAttachmentQueueEmail(TestMailgateway): +class TestAttachmentQueueEmail(TestMailCommon): def setUp(self): super().setUp() self.attach_condition_1 = self.env["fetchmail.attachment.condition"].create( @@ -31,7 +31,7 @@ def setUp(self): self.fetchmail_server = self.env["fetchmail.server"].create( { "name": "Test Fetchmail Server 1", - "type": "imap", + "server_type": "imap", "attach": True, "object_id": self.attach_queue_model.id, "attachment_condition_ids": [ @@ -41,7 +41,7 @@ def setUp(self): ) self.context_server = { "fetchmail_server_id": self.fetchmail_server.id, - "server_type": self.fetchmail_server.type, + "server_type": self.fetchmail_server.server_type, } def test_message_single_binary(self): @@ -49,15 +49,16 @@ def test_message_single_binary(self): is created """ self.assertFalse( - self.env["attachment.queue"].search([("datas_fname", "=", "thetruth.pdf")]) + self.env["attachment.queue"].search([("name", "=", "thetruth.pdf")]) ) self.env["mail.thread"].with_context(self.context_server).message_process( - self.fetchmail_server.object_id.model, MAIL_SINGLE_BINARY, + self.fetchmail_server.object_id.model, + MAIL_SINGLE_BINARY, ) attach_queue = self.env["attachment.queue"].search( - [("datas_fname", "=", "thetruth.pdf")] + [("name", "=", "thetruth.pdf")] ) self.assertEqual(len(attach_queue), 1) self.assertEqual(attach_queue.datas, b"SSBhbSB0aGUgQmF0TWFuCg==") @@ -66,10 +67,11 @@ def test_message_multi_image(self): mail = MAIL_MULTIPART_IMAGE.format(subject="Wonderful pictures", to="") self.env["mail.thread"].with_context(self.context_server).message_process( - self.fetchmail_server.object_id.model, mail, + self.fetchmail_server.object_id.model, + mail, ) attach_queues = self.env["attachment.queue"].search( - [("datas_fname", "like", ".gif")] + [("name", "like", ".gif")] ) self.assertEqual(len(attach_queues), 3) - self.assertEqual(attach_queues[0].datas_fname, "orangée.gif") + self.assertEqual(attach_queues[0].name, "orangée.gif") diff --git a/attachment_queue_email/views/fetchmail_views.xml b/attachment_queue_email/views/fetchmail_views.xml index d492dbfa6a1..4f2892d98ab 100644 --- a/attachment_queue_email/views/fetchmail_views.xml +++ b/attachment_queue_email/views/fetchmail_views.xml @@ -1,16 +1,20 @@ - + fetchmail.server - + - + - + @@ -22,11 +26,11 @@ fetchmail.attachment.condition - - - - - + + + + + @@ -40,7 +44,7 @@
    From 886aef7041662ac8418691d9d28c68384c516f6e Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Tue, 2 Nov 2021 00:35:58 +0100 Subject: [PATCH 10/16] Fix attachment_queue_email --- attachment_queue_email/models/attachment_queue.py | 2 +- attachment_queue_email/tests/test_attachment_queue_email.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index 86008d16b0d..e5550933268 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -61,7 +61,7 @@ def _prepare_data_for_attachment_queue(self, msg): :rtype: list """ res = [] - server_id = self.env.context.get("fetchmail_server_id", False) + server_id = self.env.context.get("default_fetchmail_server_id", False) file_condition_obj = self.env["fetchmail.attachment.condition"] conds = file_condition_obj.search([("server_id", "=", server_id)]) for cond in conds: diff --git a/attachment_queue_email/tests/test_attachment_queue_email.py b/attachment_queue_email/tests/test_attachment_queue_email.py index f31afda0d09..752559ee276 100644 --- a/attachment_queue_email/tests/test_attachment_queue_email.py +++ b/attachment_queue_email/tests/test_attachment_queue_email.py @@ -40,8 +40,7 @@ def setUp(self): } ) self.context_server = { - "fetchmail_server_id": self.fetchmail_server.id, - "server_type": self.fetchmail_server.server_type, + "default_fetchmail_server_id": self.fetchmail_server.id, } def test_message_single_binary(self): From 5ae51e475296d1d546828dabab92c3c3a014c998 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Tue, 6 Dec 2022 10:45:10 +0100 Subject: [PATCH 11/16] [IMP] attachment_queue_email: black, isort, prettier --- attachment_queue_email/tests/test_attachment_queue_email.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/attachment_queue_email/tests/test_attachment_queue_email.py b/attachment_queue_email/tests/test_attachment_queue_email.py index 752559ee276..559112c16e4 100644 --- a/attachment_queue_email/tests/test_attachment_queue_email.py +++ b/attachment_queue_email/tests/test_attachment_queue_email.py @@ -69,8 +69,6 @@ def test_message_multi_image(self): self.fetchmail_server.object_id.model, mail, ) - attach_queues = self.env["attachment.queue"].search( - [("name", "like", ".gif")] - ) + attach_queues = self.env["attachment.queue"].search([("name", "like", ".gif")]) self.assertEqual(len(attach_queues), 3) self.assertEqual(attach_queues[0].name, "orangée.gif") From 11b4ac00e32ee08b1b21bf58f547dde8c490e352 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Tue, 6 Dec 2022 10:49:37 +0100 Subject: [PATCH 12/16] [16.0][MIG] attachment_queue_email --- attachment_queue_email/__manifest__.py | 4 ++-- attachment_queue_email/models/attachment_queue.py | 11 ++++++++--- attachment_queue_email/models/fetchmail.py | 3 --- .../tests/test_attachment_queue_email.py | 4 ++-- attachment_queue_email/views/fetchmail_views.xml | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/attachment_queue_email/__manifest__.py b/attachment_queue_email/__manifest__.py index f4838c5b9e0..8e8ab541c23 100644 --- a/attachment_queue_email/__manifest__.py +++ b/attachment_queue_email/__manifest__.py @@ -5,13 +5,13 @@ { "name": "File Email", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "author": "Akretion,Odoo Community Association (OCA)", "category": "Generic Modules", "license": "AGPL-3", "website": "https://github.com/OCA/server-tools", "maintainers": ["florian-dacosta", "sebastienbeau", "bealdav"], - "depends": ["attachment_queue", "fetchmail"], + "depends": ["attachment_queue", "mail"], "demo": [], "data": ["security/ir.model.access.csv", "views/fetchmail_views.xml"], "installable": True, diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index e5550933268..dd3f4c1e5a0 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -24,11 +24,16 @@ class AttachmentQueue(models.Model): @api.model def _get_attachment_queue_data(self, condition, msg, att): + data = att[1] + # seems files are byte when it comes from zip file so we manage + # both case + if isinstance(data, str): + data = data.encode() values = { "fetchmail_attachment_condition_id": condition.id, "file_type": condition.file_type, - "name": att.fname, - "datas": base64.b64encode(att.content), + "name": att[0], + "datas": base64.b64encode(data), "state": "pending", } return values @@ -44,7 +49,7 @@ def prepare_data_from_basic_condition(self, cond, msg): if match_from and match_subj: for att in msg["attachments"]: - if cond.file_extension in att.fname or not cond.file_extension: + if cond.file_extension in att[0] or not cond.file_extension: vals_list.append(self._get_attachment_queue_data(cond, msg, att)) return vals_list diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index cb5c9f2cf5f..2f9abf60578 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -40,18 +40,15 @@ class FetchmailAttachmentCondition(models.Model): required=True, ) email_from = fields.Char( - string="Email From", help="If empty, catches the emails from every senders.\n" "Otherwise catches the emails where the sender's email contains the given " "characters", ) email_subject = fields.Char( - string="Email Subject", help="If empty, catches the emails with every kind of Subjects.\n" "Otherwise catches the emails where the Subject contains the given characters", ) file_extension = fields.Char( - string="File Extension", help="The extension (or part of the name) of the sought files. " "If empty, all the email's attachments will be imported.", ) diff --git a/attachment_queue_email/tests/test_attachment_queue_email.py b/attachment_queue_email/tests/test_attachment_queue_email.py index 559112c16e4..182ce08f76f 100644 --- a/attachment_queue_email/tests/test_attachment_queue_email.py +++ b/attachment_queue_email/tests/test_attachment_queue_email.py @@ -51,7 +51,7 @@ def test_message_single_binary(self): self.env["attachment.queue"].search([("name", "=", "thetruth.pdf")]) ) - self.env["mail.thread"].with_context(self.context_server).message_process( + self.env["mail.thread"].with_context(**self.context_server).message_process( self.fetchmail_server.object_id.model, MAIL_SINGLE_BINARY, ) @@ -65,7 +65,7 @@ def test_message_single_binary(self): def test_message_multi_image(self): mail = MAIL_MULTIPART_IMAGE.format(subject="Wonderful pictures", to="") - self.env["mail.thread"].with_context(self.context_server).message_process( + self.env["mail.thread"].with_context(**self.context_server).message_process( self.fetchmail_server.object_id.model, mail, ) diff --git a/attachment_queue_email/views/fetchmail_views.xml b/attachment_queue_email/views/fetchmail_views.xml index 4f2892d98ab..12a16f35644 100644 --- a/attachment_queue_email/views/fetchmail_views.xml +++ b/attachment_queue_email/views/fetchmail_views.xml @@ -3,7 +3,7 @@ fetchmail.server - + - - + + From 19d720f6fa7bfe24286349b5e3583964e987e194 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Thu, 7 Dec 2023 14:21:17 +0100 Subject: [PATCH 13/16] [IMP] Change company_id default because of deprecated method --- attachment_queue_email/models/fetchmail.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail.py index 2f9abf60578..d0aca57a5cc 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail.py @@ -6,12 +6,11 @@ class FetchmailServer(models.Model): _inherit = "fetchmail.server" - def company_default_get(self): - company_id = self.env["res.company"]._company_default_get("fetchmail.server") - return self.env["res.company"].browse(company_id).id - company_id = fields.Many2one( - "res.company", string="Company", required=True, default=company_default_get + "res.company", + string="Company", + required=True, + default=lambda self: self.env.company, ) attachment_condition_ids = fields.One2many( "fetchmail.attachment.condition", From 2196a081859457a8433d29a3a105dccfa0202874 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Mon, 12 May 2025 15:39:30 +0200 Subject: [PATCH 14/16] [REF] attachment_queue_email : move company_id from server to conditions + add email to criterias, it can be usefull to differenciate condition adding +xxx on the recipient email --- attachment_queue_email/README.rst | 45 +++++++++----- attachment_queue_email/__manifest__.py | 9 ++- attachment_queue_email/models/__init__.py | 3 +- .../models/attachment_queue.py | 16 ++++- ...l.py => fetchmail_attachment_condition.py} | 41 ++++--------- .../models/fetchmail_server.py | 24 ++++++++ attachment_queue_email/readme/DESCRIPTION.rst | 2 +- .../static/description/index.html | 60 ++++++++++--------- ...xml => fetchmail_attachment_condition.xml} | 23 ++----- .../views/fetchmail_server.xml | 16 +++++ 10 files changed, 144 insertions(+), 95 deletions(-) rename attachment_queue_email/models/{fetchmail.py => fetchmail_attachment_condition.py} (65%) create mode 100644 attachment_queue_email/models/fetchmail_server.py rename attachment_queue_email/views/{fetchmail_views.xml => fetchmail_attachment_condition.xml} (70%) create mode 100644 attachment_queue_email/views/fetchmail_server.xml diff --git a/attachment_queue_email/README.rst b/attachment_queue_email/README.rst index c1884f4edcf..89d5afe3bdd 100644 --- a/attachment_queue_email/README.rst +++ b/attachment_queue_email/README.rst @@ -1,11 +1,14 @@ -========== -File Email -========== +====================== +Attachment Queue Email +====================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:458802e95b02badcdc94837bdd0e60981bd9d184543efd4a45611ab6b20cfb41 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -14,20 +17,20 @@ File Email :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/server-tools/tree/12.0/attachment_queue_email + :target: https://github.com/OCA/server-tools/tree/16.0/attachment_queue_email :alt: OCA/server-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-attachment_queue_email + :target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-attachment_queue_email :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/149/12.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| Abstract module for importing emails attachments. -Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. +Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. **Table of contents** @@ -48,8 +51,8 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -82,6 +85,20 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/server-tools `_ project on GitHub. +.. |maintainer-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px + :target: https://github.com/florian-dacosta + :alt: florian-dacosta +.. |maintainer-sebastienbeau| image:: https://github.com/sebastienbeau.png?size=40px + :target: https://github.com/sebastienbeau + :alt: sebastienbeau +.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px + :target: https://github.com/bealdav + :alt: bealdav + +Current `maintainers `__: + +|maintainer-florian-dacosta| |maintainer-sebastienbeau| |maintainer-bealdav| + +This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/attachment_queue_email/__manifest__.py b/attachment_queue_email/__manifest__.py index 8e8ab541c23..ce268dfa9dd 100644 --- a/attachment_queue_email/__manifest__.py +++ b/attachment_queue_email/__manifest__.py @@ -4,16 +4,21 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - "name": "File Email", + "name": "Attachment Queue Email", "version": "16.0.1.0.0", "author": "Akretion,Odoo Community Association (OCA)", "category": "Generic Modules", + "summary": "Create attachment from emails to be processed depending on their type", "license": "AGPL-3", "website": "https://github.com/OCA/server-tools", "maintainers": ["florian-dacosta", "sebastienbeau", "bealdav"], "depends": ["attachment_queue", "mail"], "demo": [], - "data": ["security/ir.model.access.csv", "views/fetchmail_views.xml"], + "data": [ + "security/ir.model.access.csv", + "views/fetchmail_attachment_condition.xml", + "views/fetchmail_server.xml", + ], "installable": True, "images": [], } diff --git a/attachment_queue_email/models/__init__.py b/attachment_queue_email/models/__init__.py index ea9e3915ab1..b95e9fad4c1 100644 --- a/attachment_queue_email/models/__init__.py +++ b/attachment_queue_email/models/__init__.py @@ -1,2 +1,3 @@ from . import attachment_queue -from . import fetchmail +from . import fetchmail_server +from . import fetchmail_attachment_condition diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index dd3f4c1e5a0..df724872b20 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -35,6 +35,7 @@ def _get_attachment_queue_data(self, condition, msg, att): "name": att[0], "datas": base64.b64encode(data), "state": "pending", + "company_id": condition.company_id.id, } return values @@ -42,12 +43,21 @@ def _get_attachment_queue_data(self, condition, msg, att): def prepare_data_from_basic_condition(self, cond, msg): vals_list = [] # match_from and match_subj are True if empty or if matching with msg's values - match_from = str(cond.email_from) in msg.get("from", "") or not cond.email_from + match_from = ( + cond.email_from + and cond.email_from in msg.get("from", "") + or not cond.email_from + ) match_subj = ( - str(cond.email_subject) in msg.get("subject", "") or not cond.email_subject + cond.email_subject + and cond.email_subject in msg.get("subject", "") + or not cond.email_subject + ) + match_to = ( + cond.email_to and cond.email_to in msg.get("to", "") or not cond.email_to ) - if match_from and match_subj: + if match_from and match_subj and match_to: for att in msg["attachments"]: if cond.file_extension in att[0] or not cond.file_extension: vals_list.append(self._get_attachment_queue_data(cond, msg, att)) diff --git a/attachment_queue_email/models/fetchmail.py b/attachment_queue_email/models/fetchmail_attachment_condition.py similarity index 65% rename from attachment_queue_email/models/fetchmail.py rename to attachment_queue_email/models/fetchmail_attachment_condition.py index d0aca57a5cc..8515613b759 100644 --- a/attachment_queue_email/models/fetchmail.py +++ b/attachment_queue_email/models/fetchmail_attachment_condition.py @@ -1,38 +1,12 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models - - -class FetchmailServer(models.Model): - _inherit = "fetchmail.server" - - company_id = fields.Many2one( - "res.company", - string="Company", - required=True, - default=lambda self: self.env.company, - ) - attachment_condition_ids = fields.One2many( - "fetchmail.attachment.condition", - "server_id", - string="Attachment Condition", - help="Files attached to the emails matching these conditions will be imported " - "in Odoo as 'Attachment Queue' objects", - ) - - @api.onchange("attachment_condition_ids") - def onchange_attachment_condition(self): - for server in self: - if server.attachment_condition_ids: - server.object_id = self.env["ir.model"].search( - [("model", "=", "attachment.queue")] - ) - server.attach = True +from odoo import fields, models class FetchmailAttachmentCondition(models.Model): _name = "fetchmail.attachment.condition" _description = "Fetchmail Attachment Conditions" + _check_company_auto = True name = fields.Char( string="Condition Name", @@ -43,6 +17,11 @@ class FetchmailAttachmentCondition(models.Model): "Otherwise catches the emails where the sender's email contains the given " "characters", ) + email_to = fields.Char( + help="If empty, catches the email no matter the recipient.\n" + "Otherwise catches the emails where the recipients emails contains the given " + "characters.", + ) email_subject = fields.Char( help="If empty, catches the emails with every kind of Subjects.\n" "Otherwise catches the emails where the Subject contains the given characters", @@ -58,3 +37,9 @@ class FetchmailAttachmentCondition(models.Model): "from the selected emails attachments.\nIt will allow Odoo to recognize " "what do do with them once created.", ) + company_id = fields.Many2one( + "res.company", + string="Company", + required=True, + default=lambda self: self.env.company, + ) diff --git a/attachment_queue_email/models/fetchmail_server.py b/attachment_queue_email/models/fetchmail_server.py new file mode 100644 index 00000000000..3d1ec00bfb4 --- /dev/null +++ b/attachment_queue_email/models/fetchmail_server.py @@ -0,0 +1,24 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class FetchmailServer(models.Model): + _inherit = "fetchmail.server" + + attachment_condition_ids = fields.One2many( + "fetchmail.attachment.condition", + "server_id", + string="Attachment Condition", + help="Files attached to the emails matching these conditions will be imported " + "in Odoo as 'Attachment Queue' objects", + ) + + @api.onchange("attachment_condition_ids") + def onchange_attachment_condition(self): + for server in self: + if server.attachment_condition_ids: + server.object_id = self.env["ir.model"].search( + [("model", "=", "attachment.queue")] + ) + server.attach = True diff --git a/attachment_queue_email/readme/DESCRIPTION.rst b/attachment_queue_email/readme/DESCRIPTION.rst index 5567bfeecf2..9099c5efd2a 100644 --- a/attachment_queue_email/readme/DESCRIPTION.rst +++ b/attachment_queue_email/readme/DESCRIPTION.rst @@ -1,3 +1,3 @@ Abstract module for importing emails attachments. -Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. +Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. diff --git a/attachment_queue_email/static/description/index.html b/attachment_queue_email/static/description/index.html index d367371bd87..77770aa7383 100644 --- a/attachment_queue_email/static/description/index.html +++ b/attachment_queue_email/static/description/index.html @@ -1,20 +1,20 @@ - - -File Email + +Attachment Queue Email -
    -

    File Email

    +
    +

    Attachment Queue Email

    -

    Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

    +

    Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

    Abstract module for importing emails attachments.

    -

    Each email’s attachment matching a given “Attachment Condition” will be imported creating a new attachment.queue object. These attachment.queue objects are files wrapped with additional fields (mainly a Filed Type and a State) making them ready to be processed by a custom module as you can read in the attachment_queue documentation.

    +

    Each email’s attachment matching a given “Attachment Condition” will be imported creating a new attachment.queue object. These attachment.queue objects are files wrapped with additional fields (mainly a Filed Type and a State) making them ready to be processed by a custom module as you can read in the attachment_queue documentation.

    Table of contents

    -

    Usage

    +

    Usage

    Adding an “Attachment Condition” to your Incoming Mail Server configuration will lead to the creation of attachment.queue objects from emails attachments coming from this server and matching the given Attachment Condition.

    🔎 Recalling that, as the Incoming Mail Servers has only one “Create a New Record” field, the emails coming from that server cannot be used to create other type of objects than attachment.queue.

    Filling the condition’s File Type field will spread this value to the newly created attchment.queue objects so they can be processed by a custom module following this File Type field value.

    -

    Bug Tracker

    +

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

    +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

    Do not contact contributors directly about support or help with technical issues.

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Akretion
    -

    Contributors

    +

    Contributors

    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/server-tools project on GitHub.

    +

    Current maintainers:

    +

    florian-dacosta sebastienbeau bealdav

    +

    This module is part of the OCA/server-tools project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/attachment_queue_email/views/fetchmail_views.xml b/attachment_queue_email/views/fetchmail_attachment_condition.xml similarity index 70% rename from attachment_queue_email/views/fetchmail_views.xml rename to attachment_queue_email/views/fetchmail_attachment_condition.xml index 12a16f35644..e02db7aa17a 100644 --- a/attachment_queue_email/views/fetchmail_views.xml +++ b/attachment_queue_email/views/fetchmail_attachment_condition.xml @@ -1,25 +1,6 @@ - - fetchmail.server - - - - - - - - - - - - - view_fetchmail_attachment_condition_tree @@ -28,9 +9,11 @@ + + @@ -48,7 +31,9 @@
    + + diff --git a/attachment_queue_email/views/fetchmail_server.xml b/attachment_queue_email/views/fetchmail_server.xml new file mode 100644 index 00000000000..986979b917a --- /dev/null +++ b/attachment_queue_email/views/fetchmail_server.xml @@ -0,0 +1,16 @@ + + + + + fetchmail.server + + + + + + + + + + + From 28ede614d7f4d8e6a75ab65248d457a8e990978d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Tue, 15 Sep 2026 15:57:48 +0200 Subject: [PATCH 15/16] [IMP] attachment_queue_email: pre-commit auto fixes --- attachment_queue_email/README.rst | 46 ++++++++++++------- attachment_queue_email/pyproject.toml | 3 ++ attachment_queue_email/readme/CONTRIBUTORS.md | 4 ++ .../readme/CONTRIBUTORS.rst | 4 -- attachment_queue_email/readme/DESCRIPTION.md | 9 ++++ attachment_queue_email/readme/DESCRIPTION.rst | 3 -- attachment_queue_email/readme/USAGE.md | 13 ++++++ attachment_queue_email/readme/USAGE.rst | 5 -- .../static/description/index.html | 28 ++++++++--- .../views/fetchmail_attachment_condition.xml | 20 ++++---- .../views/fetchmail_server.xml | 4 +- 11 files changed, 90 insertions(+), 49 deletions(-) create mode 100644 attachment_queue_email/pyproject.toml create mode 100644 attachment_queue_email/readme/CONTRIBUTORS.md delete mode 100644 attachment_queue_email/readme/CONTRIBUTORS.rst create mode 100644 attachment_queue_email/readme/DESCRIPTION.md delete mode 100644 attachment_queue_email/readme/DESCRIPTION.rst create mode 100644 attachment_queue_email/readme/USAGE.md delete mode 100644 attachment_queue_email/readme/USAGE.rst diff --git a/attachment_queue_email/README.rst b/attachment_queue_email/README.rst index 89d5afe3bdd..75dbf55b739 100644 --- a/attachment_queue_email/README.rst +++ b/attachment_queue_email/README.rst @@ -17,20 +17,26 @@ Attachment Queue Email :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/server-tools/tree/16.0/attachment_queue_email + :target: https://github.com/OCA/server-tools/tree/18.0/attachment_queue_email :alt: OCA/server-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-attachment_queue_email + :target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-attachment_queue_email :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| Abstract module for importing emails attachments. -Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. +Each email's attachment matching a given **"Attachment Condition"** will +be imported creating a new ``attachment.queue`` object. These +``attachment.queue`` objects are files wrapped with additional fields +(mainly a **Filed Type** and a **State**) making them ready to be +processed by a custom module as you can read in the +`attachment_queue `__ +documentation. **Table of contents** @@ -40,11 +46,19 @@ Each email's attachment matching a given **"Attachment Condition"** will be impo Usage ===== -Adding an **"Attachment Condition"** to your *Incoming Mail Server* configuration will lead to the creation of ``attachment.queue`` objects from emails attachments coming from this server and matching the given *Attachment Condition*. +Adding an **"Attachment Condition"** to your *Incoming Mail Server* +configuration will lead to the creation of ``attachment.queue`` objects +from emails attachments coming from this server and matching the given +*Attachment Condition*. - 🔎 Recalling that, as the *Incoming Mail Servers* has only one *"Create a New Record"* field, the emails coming from that server **cannot be used to create other type of objects** than ``attachment.queue``. + 🔎 Recalling that, as the *Incoming Mail Servers* has only one + *"Create a New Record"* field, the emails coming from that server + **cannot be used to create other type of objects** than + ``attachment.queue``. -Filling the condition's **File Type** field will spread this value to the newly created ``attchment.queue`` objects so they can be processed by a custom module following this **File Type** field value. +Filling the condition's **File Type** field will spread this value to +the newly created ``attchment.queue`` objects so they can be processed +by a custom module following this **File Type** field value. Bug Tracker =========== @@ -52,7 +66,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -60,20 +74,20 @@ Credits ======= Authors -~~~~~~~ +------- * Akretion Contributors -~~~~~~~~~~~~ +------------ -* Valentin CHEMIERE -* Florian DA COSTA -* Sebastien BEAU -* Clément Mombereau +- Valentin CHEMIERE +- Florian DA COSTA +- Sebastien BEAU +- Clément Mombereau Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -99,6 +113,6 @@ Current `maintainers `__: |maintainer-florian-dacosta| |maintainer-sebastienbeau| |maintainer-bealdav| -This module is part of the `OCA/server-tools `_ project on GitHub. +This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/attachment_queue_email/pyproject.toml b/attachment_queue_email/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/attachment_queue_email/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/attachment_queue_email/readme/CONTRIBUTORS.md b/attachment_queue_email/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..815ca1c7982 --- /dev/null +++ b/attachment_queue_email/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Valentin CHEMIERE \ +- Florian DA COSTA \ +- Sebastien BEAU \ +- Clément Mombereau \ diff --git a/attachment_queue_email/readme/CONTRIBUTORS.rst b/attachment_queue_email/readme/CONTRIBUTORS.rst deleted file mode 100644 index 254561ed783..00000000000 --- a/attachment_queue_email/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,4 +0,0 @@ -* Valentin CHEMIERE -* Florian DA COSTA -* Sebastien BEAU -* Clément Mombereau diff --git a/attachment_queue_email/readme/DESCRIPTION.md b/attachment_queue_email/readme/DESCRIPTION.md new file mode 100644 index 00000000000..949bf8a5409 --- /dev/null +++ b/attachment_queue_email/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +Abstract module for importing emails attachments. + +Each email's attachment matching a given **"Attachment Condition"** will +be imported creating a new `attachment.queue` object. These +`attachment.queue` objects are files wrapped with additional fields +(mainly a **Filed Type** and a **State**) making them ready to be +processed by a custom module as you can read in the +[attachment_queue](https://github.com/OCA/server-tools/tree/16.0/attachment_queue) +documentation. diff --git a/attachment_queue_email/readme/DESCRIPTION.rst b/attachment_queue_email/readme/DESCRIPTION.rst deleted file mode 100644 index 9099c5efd2a..00000000000 --- a/attachment_queue_email/readme/DESCRIPTION.rst +++ /dev/null @@ -1,3 +0,0 @@ -Abstract module for importing emails attachments. - -Each email's attachment matching a given **"Attachment Condition"** will be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the `attachment_queue `_ documentation. diff --git a/attachment_queue_email/readme/USAGE.md b/attachment_queue_email/readme/USAGE.md new file mode 100644 index 00000000000..8d3ca619408 --- /dev/null +++ b/attachment_queue_email/readme/USAGE.md @@ -0,0 +1,13 @@ +Adding an **"Attachment Condition"** to your *Incoming Mail Server* +configuration will lead to the creation of `attachment.queue` objects +from emails attachments coming from this server and matching the given +*Attachment Condition*. + +> 🔎 Recalling that, as the *Incoming Mail Servers* has only one +> *"Create a New Record"* field, the emails coming from that server +> **cannot be used to create other type of objects** than +> `attachment.queue`. + +Filling the condition's **File Type** field will spread this value to +the newly created `attchment.queue` objects so they can be processed by +a custom module following this **File Type** field value. diff --git a/attachment_queue_email/readme/USAGE.rst b/attachment_queue_email/readme/USAGE.rst deleted file mode 100644 index 41c2a45c2df..00000000000 --- a/attachment_queue_email/readme/USAGE.rst +++ /dev/null @@ -1,5 +0,0 @@ -Adding an **"Attachment Condition"** to your *Incoming Mail Server* configuration will lead to the creation of ``attachment.queue`` objects from emails attachments coming from this server and matching the given *Attachment Condition*. - - 🔎 Recalling that, as the *Incoming Mail Servers* has only one *"Create a New Record"* field, the emails coming from that server **cannot be used to create other type of objects** than ``attachment.queue``. - -Filling the condition's **File Type** field will spread this value to the newly created ``attchment.queue`` objects so they can be processed by a custom module following this **File Type** field value. diff --git a/attachment_queue_email/static/description/index.html b/attachment_queue_email/static/description/index.html index 77770aa7383..2d760451376 100644 --- a/attachment_queue_email/static/description/index.html +++ b/attachment_queue_email/static/description/index.html @@ -369,9 +369,15 @@

    Attachment Queue Email

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:458802e95b02badcdc94837bdd0e60981bd9d184543efd4a45611ab6b20cfb41 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

    Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

    +

    Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

    Abstract module for importing emails attachments.

    -

    Each email’s attachment matching a given “Attachment Condition” will be imported creating a new attachment.queue object. These attachment.queue objects are files wrapped with additional fields (mainly a Filed Type and a State) making them ready to be processed by a custom module as you can read in the attachment_queue documentation.

    +

    Each email’s attachment matching a given “Attachment Condition” will +be imported creating a new attachment.queue object. These +attachment.queue objects are files wrapped with additional fields +(mainly a Filed Type and a State) making them ready to be +processed by a custom module as you can read in the +attachment_queue +documentation.

    Table of contents

      @@ -387,17 +393,25 @@

      Attachment Queue Email

    Usage

    -

    Adding an “Attachment Condition” to your Incoming Mail Server configuration will lead to the creation of attachment.queue objects from emails attachments coming from this server and matching the given Attachment Condition.

    +

    Adding an “Attachment Condition” to your Incoming Mail Server +configuration will lead to the creation of attachment.queue objects +from emails attachments coming from this server and matching the given +Attachment Condition.

    -🔎 Recalling that, as the Incoming Mail Servers has only one “Create a New Record” field, the emails coming from that server cannot be used to create other type of objects than attachment.queue.
    -

    Filling the condition’s File Type field will spread this value to the newly created attchment.queue objects so they can be processed by a custom module following this File Type field value.

    +🔎 Recalling that, as the Incoming Mail Servers has only one +“Create a New Record” field, the emails coming from that server +cannot be used to create other type of objects than +attachment.queue. +

    Filling the condition’s File Type field will spread this value to +the newly created attchment.queue objects so they can be processed +by a custom module following this File Type field value.

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -428,7 +442,7 @@

    Maintainers

    promote its widespread use.

    Current maintainers:

    florian-dacosta sebastienbeau bealdav

    -

    This module is part of the OCA/server-tools project on GitHub.

    +

    This module is part of the OCA/server-tools project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/attachment_queue_email/views/fetchmail_attachment_condition.xml b/attachment_queue_email/views/fetchmail_attachment_condition.xml index e02db7aa17a..039b57a471a 100644 --- a/attachment_queue_email/views/fetchmail_attachment_condition.xml +++ b/attachment_queue_email/views/fetchmail_attachment_condition.xml @@ -1,7 +1,6 @@ - - + view_fetchmail_attachment_condition_tree fetchmail.attachment.condition @@ -15,7 +14,7 @@ - + @@ -24,12 +23,12 @@
    -
    -
    +
    +
    @@ -43,7 +42,6 @@
    -
    +
    -
    diff --git a/attachment_queue_email/views/fetchmail_server.xml b/attachment_queue_email/views/fetchmail_server.xml index 986979b917a..0f7c855d670 100644 --- a/attachment_queue_email/views/fetchmail_server.xml +++ b/attachment_queue_email/views/fetchmail_server.xml @@ -1,6 +1,5 @@ - fetchmail.server @@ -8,9 +7,8 @@ - + - From 8f96ae6a3c1b50a40d5bcdcfbf4415ca65bf46e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Tue, 15 Sep 2026 15:57:48 +0200 Subject: [PATCH 16/16] [MIG] attachment_queue_email: Migration to 18.0 --- attachment_queue_email/README.rst | 5 +-- attachment_queue_email/__manifest__.py | 8 ++--- .../models/attachment_queue.py | 34 +++++++++++-------- .../models/fetchmail_attachment_condition.py | 4 +-- .../models/fetchmail_server.py | 3 +- attachment_queue_email/readme/CONTRIBUTORS.md | 3 +- attachment_queue_email/readme/DESCRIPTION.md | 2 +- .../security/ir.model.access.csv | 2 +- .../static/description/index.html | 5 +-- .../tests/test_attachment_queue_email.py | 4 +-- .../views/fetchmail_attachment_condition.xml | 6 ++-- 11 files changed, 42 insertions(+), 34 deletions(-) diff --git a/attachment_queue_email/README.rst b/attachment_queue_email/README.rst index 75dbf55b739..7cee8a78ab1 100644 --- a/attachment_queue_email/README.rst +++ b/attachment_queue_email/README.rst @@ -35,7 +35,7 @@ be imported creating a new ``attachment.queue`` object. These ``attachment.queue`` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the -`attachment_queue `__ +`attachment_queue `__ documentation. **Table of contents** @@ -84,7 +84,8 @@ Contributors - Valentin CHEMIERE - Florian DA COSTA - Sebastien BEAU -- Clément Mombereau +- Clément Mombereau +- Benoit GUILLOT Maintainers ----------- diff --git a/attachment_queue_email/__manifest__.py b/attachment_queue_email/__manifest__.py index ce268dfa9dd..051130f2237 100644 --- a/attachment_queue_email/__manifest__.py +++ b/attachment_queue_email/__manifest__.py @@ -1,11 +1,9 @@ -# @author Sébastien BEAU @ Akretion -# @author Florian DA COSTA @ Akretion -# @author Benoit GUILLOT @ Akretion -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2012 Akretion (https://www.akretion.com). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) { "name": "Attachment Queue Email", - "version": "16.0.1.0.0", + "version": "18.0.1.0.0", "author": "Akretion,Odoo Community Association (OCA)", "category": "Generic Modules", "summary": "Create attachment from emails to be processed depending on their type", diff --git a/attachment_queue_email/models/attachment_queue.py b/attachment_queue_email/models/attachment_queue.py index df724872b20..62446c1ca14 100644 --- a/attachment_queue_email/models/attachment_queue.py +++ b/attachment_queue_email/models/attachment_queue.py @@ -1,4 +1,5 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2012 Akretion (https://www.akretion.com). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) import base64 @@ -40,36 +41,41 @@ def _get_attachment_queue_data(self, condition, msg, att): return values @api.model - def prepare_data_from_basic_condition(self, cond, msg): + def prepare_data_from_basic_condition(self, cond, msg_dict): vals_list = [] - # match_from and match_subj are True if empty or if matching with msg's values + # match_from and match_subj are True if empty or if matching with + # msg_dict's values match_from = ( cond.email_from - and cond.email_from in msg.get("from", "") + and cond.email_from in msg_dict.get("from", "") or not cond.email_from ) match_subj = ( cond.email_subject - and cond.email_subject in msg.get("subject", "") + and cond.email_subject in msg_dict.get("subject", "") or not cond.email_subject ) match_to = ( - cond.email_to and cond.email_to in msg.get("to", "") or not cond.email_to + cond.email_to + and cond.email_to in msg_dict.get("to", "") + or not cond.email_to ) if match_from and match_subj and match_to: - for att in msg["attachments"]: + for att in msg_dict["attachments"]: if cond.file_extension in att[0] or not cond.file_extension: - vals_list.append(self._get_attachment_queue_data(cond, msg, att)) + vals_list.append( + self._get_attachment_queue_data(cond, msg_dict, att) + ) return vals_list @api.model - def _prepare_data_for_attachment_queue(self, msg): + def _prepare_data_for_attachment_queue(self, msg_dict): """Prepare the datas for the creation of one or many attachment.queue depending on the number of the email's attachments files and if the email matches the fetchmail.attachment.condition's conditions. - :param msg: a dictionnary with the email data + :param msg_dict: a dictionnary with the email data :type: dict :return: a list of dictionnary that contains the attachment.queue data @@ -80,18 +86,18 @@ def _prepare_data_for_attachment_queue(self, msg): file_condition_obj = self.env["fetchmail.attachment.condition"] conds = file_condition_obj.search([("server_id", "=", server_id)]) for cond in conds: - vals_list = self.prepare_data_from_basic_condition(cond, msg) + vals_list = self.prepare_data_from_basic_condition(cond, msg_dict) if vals_list: res += vals_list return res @api.model - def message_new(self, msg, custom_values): - """Create Attachments Queues objects from the new received email's attachments.""" + def message_new(self, msg_dict, custom_values=None): + """Create Attachments Queues objects from the received email's attachments.""" # Rewriting completely ``message_new`` instead of overiding it in order to # allows the creation of many new objects instead of only one. created_recs = [] - res = self._prepare_data_for_attachment_queue(msg) + res = self._prepare_data_for_attachment_queue(msg_dict) if res: for vals in res: created_recs.append(self.create(vals)) diff --git a/attachment_queue_email/models/fetchmail_attachment_condition.py b/attachment_queue_email/models/fetchmail_attachment_condition.py index 8515613b759..583b2acbd9e 100644 --- a/attachment_queue_email/models/fetchmail_attachment_condition.py +++ b/attachment_queue_email/models/fetchmail_attachment_condition.py @@ -1,4 +1,5 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2012 Akretion (https://www.akretion.com). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import fields, models @@ -6,7 +7,6 @@ class FetchmailAttachmentCondition(models.Model): _name = "fetchmail.attachment.condition" _description = "Fetchmail Attachment Conditions" - _check_company_auto = True name = fields.Char( string="Condition Name", diff --git a/attachment_queue_email/models/fetchmail_server.py b/attachment_queue_email/models/fetchmail_server.py index 3d1ec00bfb4..ad04a971ebb 100644 --- a/attachment_queue_email/models/fetchmail_server.py +++ b/attachment_queue_email/models/fetchmail_server.py @@ -1,4 +1,5 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2012 Akretion (https://www.akretion.com). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) from odoo import api, fields, models diff --git a/attachment_queue_email/readme/CONTRIBUTORS.md b/attachment_queue_email/readme/CONTRIBUTORS.md index 815ca1c7982..ceb876de84d 100644 --- a/attachment_queue_email/readme/CONTRIBUTORS.md +++ b/attachment_queue_email/readme/CONTRIBUTORS.md @@ -1,4 +1,5 @@ - Valentin CHEMIERE \ - Florian DA COSTA \ - Sebastien BEAU \ -- Clément Mombereau \ +- Clément Mombereau \ +- Benoit GUILLOT \ diff --git a/attachment_queue_email/readme/DESCRIPTION.md b/attachment_queue_email/readme/DESCRIPTION.md index 949bf8a5409..2d2af96face 100644 --- a/attachment_queue_email/readme/DESCRIPTION.md +++ b/attachment_queue_email/readme/DESCRIPTION.md @@ -5,5 +5,5 @@ be imported creating a new `attachment.queue` object. These `attachment.queue` objects are files wrapped with additional fields (mainly a **Filed Type** and a **State**) making them ready to be processed by a custom module as you can read in the -[attachment_queue](https://github.com/OCA/server-tools/tree/16.0/attachment_queue) +[attachment_queue](https://github.com/OCA/server-tools/tree/18.0/attachment_queue) documentation. diff --git a/attachment_queue_email/security/ir.model.access.csv b/attachment_queue_email/security/ir.model.access.csv index 9fff725bf35..68aeab002a2 100644 --- a/attachment_queue_email/security/ir.model.access.csv +++ b/attachment_queue_email/security/ir.model.access.csv @@ -1,3 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_fetchmail_attachment_condition_manager,fetchmail.attachment.condition.user,model_fetchmail_attachment_condition,base.group_system,1,1,1,1 +access_fetchmail_attachment_condition_manager,fetchmail.attachment.condition.manager,model_fetchmail_attachment_condition,base.group_system,1,1,1,1 access_fetchmail_attachment_condition_user,fetchmail.attachment.condition.user,model_fetchmail_attachment_condition,base.group_user,1,0,0,0 diff --git a/attachment_queue_email/static/description/index.html b/attachment_queue_email/static/description/index.html index 2d760451376..2b192028c59 100644 --- a/attachment_queue_email/static/description/index.html +++ b/attachment_queue_email/static/description/index.html @@ -376,7 +376,7 @@

    Attachment Queue Email

    attachment.queue objects are files wrapped with additional fields (mainly a Filed Type and a State) making them ready to be processed by a custom module as you can read in the -attachment_queue +attachment_queue documentation.

    Table of contents

    @@ -428,7 +428,8 @@

    Contributors

  • Valentin CHEMIERE <valentin.chemiere@akretion.com>
  • Florian DA COSTA <florian.dacosta@akretion.com>
  • Sebastien BEAU <sebastian.beau@akretion.com>
  • -
  • Clément Mombereau <clement.mombereau@akretion.com.br>
  • +
  • Clément Mombereau <clement.mombereau@akretion.com>
  • +
  • Benoit GUILLOT <benoit.guillot@akretion.com>
  • diff --git a/attachment_queue_email/tests/test_attachment_queue_email.py b/attachment_queue_email/tests/test_attachment_queue_email.py index 182ce08f76f..26630c5e9e9 100644 --- a/attachment_queue_email/tests/test_attachment_queue_email.py +++ b/attachment_queue_email/tests/test_attachment_queue_email.py @@ -1,13 +1,13 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.addons.mail.tests.common import MailCommon from odoo.addons.test_mail.data.test_mail_data import ( MAIL_MULTIPART_IMAGE, MAIL_SINGLE_BINARY, ) -from odoo.addons.test_mail.tests.common import TestMailCommon -class TestAttachmentQueueEmail(TestMailCommon): +class TestAttachmentQueueEmail(MailCommon): def setUp(self): super().setUp() self.attach_condition_1 = self.env["fetchmail.attachment.condition"].create( diff --git a/attachment_queue_email/views/fetchmail_attachment_condition.xml b/attachment_queue_email/views/fetchmail_attachment_condition.xml index 039b57a471a..d833e748c3b 100644 --- a/attachment_queue_email/views/fetchmail_attachment_condition.xml +++ b/attachment_queue_email/views/fetchmail_attachment_condition.xml @@ -5,15 +5,15 @@ view_fetchmail_attachment_condition_tree fetchmail.attachment.condition - + - + - +