odoo-addon-attachment-queue-email 18.0.1.0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/attachment_queue_email/README.rst +123 -0
- odoo/addons/attachment_queue_email/__init__.py +1 -0
- odoo/addons/attachment_queue_email/__manifest__.py +22 -0
- odoo/addons/attachment_queue_email/i18n/attachment_queue_email.pot +200 -0
- odoo/addons/attachment_queue_email/models/__init__.py +3 -0
- odoo/addons/attachment_queue_email/models/attachment_queue.py +105 -0
- odoo/addons/attachment_queue_email/models/fetchmail_attachment_condition.py +45 -0
- odoo/addons/attachment_queue_email/models/fetchmail_server.py +25 -0
- odoo/addons/attachment_queue_email/readme/CONTRIBUTORS.md +5 -0
- odoo/addons/attachment_queue_email/readme/DESCRIPTION.md +9 -0
- odoo/addons/attachment_queue_email/readme/USAGE.md +13 -0
- odoo/addons/attachment_queue_email/security/ir.model.access.csv +3 -0
- odoo/addons/attachment_queue_email/static/description/icon.png +0 -0
- odoo/addons/attachment_queue_email/static/description/index.html +458 -0
- odoo/addons/attachment_queue_email/tests/__init__.py +3 -0
- odoo/addons/attachment_queue_email/tests/test_attachment_queue_email.py +74 -0
- odoo/addons/attachment_queue_email/views/fetchmail_attachment_condition.xml +47 -0
- odoo/addons/attachment_queue_email/views/fetchmail_server.xml +14 -0
- odoo_addon_attachment_queue_email-18.0.1.0.0.2.dist-info/METADATA +140 -0
- odoo_addon_attachment_queue_email-18.0.1.0.0.2.dist-info/RECORD +22 -0
- odoo_addon_attachment_queue_email-18.0.1.0.0.2.dist-info/WHEEL +5 -0
- odoo_addon_attachment_queue_email-18.0.1.0.0.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
.. image:: https://odoo-community.org/readme-banner-image
|
|
2
|
+
:target: https://odoo-community.org/get-involved?utm_source=readme
|
|
3
|
+
:alt: Odoo Community Association
|
|
4
|
+
|
|
5
|
+
======================
|
|
6
|
+
Attachment Queue Email
|
|
7
|
+
======================
|
|
8
|
+
|
|
9
|
+
..
|
|
10
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
11
|
+
!! This file is generated by oca-gen-addon-readme !!
|
|
12
|
+
!! changes will be overwritten. !!
|
|
13
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
14
|
+
!! source digest: sha256:27f9d13a667b05afb86742b7074e5ac32070df09ff3cc42906202f5a1d2a950d
|
|
15
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
16
|
+
|
|
17
|
+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
|
18
|
+
:target: https://odoo-community.org/page/development-status
|
|
19
|
+
:alt: Beta
|
|
20
|
+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
|
21
|
+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
|
22
|
+
:alt: License: AGPL-3
|
|
23
|
+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
|
|
24
|
+
:target: https://github.com/OCA/server-tools/tree/18.0/attachment_queue_email
|
|
25
|
+
:alt: OCA/server-tools
|
|
26
|
+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
|
27
|
+
:target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-attachment_queue_email
|
|
28
|
+
:alt: Translate me on Weblate
|
|
29
|
+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
|
30
|
+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0
|
|
31
|
+
:alt: Try me on Runboat
|
|
32
|
+
|
|
33
|
+
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|
34
|
+
|
|
35
|
+
Abstract module for importing emails attachments.
|
|
36
|
+
|
|
37
|
+
Each email's attachment matching a given **"Attachment Condition"** will
|
|
38
|
+
be imported creating a new ``attachment.queue`` object. These
|
|
39
|
+
``attachment.queue`` objects are files wrapped with additional fields
|
|
40
|
+
(mainly a **Filed Type** and a **State**) making them ready to be
|
|
41
|
+
processed by a custom module as you can read in the
|
|
42
|
+
`attachment_queue <https://github.com/OCA/server-tools/tree/18.0/attachment_queue>`__
|
|
43
|
+
documentation.
|
|
44
|
+
|
|
45
|
+
**Table of contents**
|
|
46
|
+
|
|
47
|
+
.. contents::
|
|
48
|
+
:local:
|
|
49
|
+
|
|
50
|
+
Usage
|
|
51
|
+
=====
|
|
52
|
+
|
|
53
|
+
Adding an **"Attachment Condition"** to your *Incoming Mail Server*
|
|
54
|
+
configuration will lead to the creation of ``attachment.queue`` objects
|
|
55
|
+
from emails attachments coming from this server and matching the given
|
|
56
|
+
*Attachment Condition*.
|
|
57
|
+
|
|
58
|
+
🔎 Recalling that, as the *Incoming Mail Servers* has only one
|
|
59
|
+
*"Create a New Record"* field, the emails coming from that server
|
|
60
|
+
**cannot be used to create other type of objects** than
|
|
61
|
+
``attachment.queue``.
|
|
62
|
+
|
|
63
|
+
Filling the condition's **File Type** field will spread this value to
|
|
64
|
+
the newly created ``attchment.queue`` objects so they can be processed
|
|
65
|
+
by a custom module following this **File Type** field value.
|
|
66
|
+
|
|
67
|
+
Bug Tracker
|
|
68
|
+
===========
|
|
69
|
+
|
|
70
|
+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
|
|
71
|
+
In case of trouble, please check there if your issue has already been reported.
|
|
72
|
+
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
|
73
|
+
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20attachment_queue_email%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
|
74
|
+
|
|
75
|
+
Do not contact contributors directly about support or help with technical issues.
|
|
76
|
+
|
|
77
|
+
Credits
|
|
78
|
+
=======
|
|
79
|
+
|
|
80
|
+
Authors
|
|
81
|
+
-------
|
|
82
|
+
|
|
83
|
+
* Akretion
|
|
84
|
+
|
|
85
|
+
Contributors
|
|
86
|
+
------------
|
|
87
|
+
|
|
88
|
+
- Valentin CHEMIERE <valentin.chemiere@akretion.com>
|
|
89
|
+
- Florian DA COSTA <florian.dacosta@akretion.com>
|
|
90
|
+
- Sebastien BEAU <sebastian.beau@akretion.com>
|
|
91
|
+
- Clément Mombereau <clement.mombereau@akretion.com>
|
|
92
|
+
- Benoit GUILLOT <benoit.guillot@akretion.com>
|
|
93
|
+
|
|
94
|
+
Maintainers
|
|
95
|
+
-----------
|
|
96
|
+
|
|
97
|
+
This module is maintained by the OCA.
|
|
98
|
+
|
|
99
|
+
.. image:: https://odoo-community.org/logo.png
|
|
100
|
+
:alt: Odoo Community Association
|
|
101
|
+
:target: https://odoo-community.org
|
|
102
|
+
|
|
103
|
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|
104
|
+
mission is to support the collaborative development of Odoo features and
|
|
105
|
+
promote its widespread use.
|
|
106
|
+
|
|
107
|
+
.. |maintainer-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px
|
|
108
|
+
:target: https://github.com/florian-dacosta
|
|
109
|
+
:alt: florian-dacosta
|
|
110
|
+
.. |maintainer-sebastienbeau| image:: https://github.com/sebastienbeau.png?size=40px
|
|
111
|
+
:target: https://github.com/sebastienbeau
|
|
112
|
+
:alt: sebastienbeau
|
|
113
|
+
.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px
|
|
114
|
+
:target: https://github.com/bealdav
|
|
115
|
+
:alt: bealdav
|
|
116
|
+
|
|
117
|
+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|
|
118
|
+
|
|
119
|
+
|maintainer-florian-dacosta| |maintainer-sebastienbeau| |maintainer-bealdav|
|
|
120
|
+
|
|
121
|
+
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/18.0/attachment_queue_email>`_ project on GitHub.
|
|
122
|
+
|
|
123
|
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import models
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2012 Akretion (https://www.akretion.com).
|
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
|
3
|
+
|
|
4
|
+
{
|
|
5
|
+
"name": "Attachment Queue Email",
|
|
6
|
+
"version": "18.0.1.0.0",
|
|
7
|
+
"author": "Akretion,Odoo Community Association (OCA)",
|
|
8
|
+
"category": "Generic Modules",
|
|
9
|
+
"summary": "Create attachment from emails to be processed depending on their type",
|
|
10
|
+
"license": "AGPL-3",
|
|
11
|
+
"website": "https://github.com/OCA/server-tools",
|
|
12
|
+
"maintainers": ["florian-dacosta", "sebastienbeau", "bealdav"],
|
|
13
|
+
"depends": ["attachment_queue", "mail"],
|
|
14
|
+
"demo": [],
|
|
15
|
+
"data": [
|
|
16
|
+
"security/ir.model.access.csv",
|
|
17
|
+
"views/fetchmail_attachment_condition.xml",
|
|
18
|
+
"views/fetchmail_server.xml",
|
|
19
|
+
],
|
|
20
|
+
"installable": True,
|
|
21
|
+
"images": [],
|
|
22
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Translation of Odoo Server.
|
|
2
|
+
# This file contains the translation of the following modules:
|
|
3
|
+
# * attachment_queue_email
|
|
4
|
+
#
|
|
5
|
+
msgid ""
|
|
6
|
+
msgstr ""
|
|
7
|
+
"Project-Id-Version: Odoo Server 18.0\n"
|
|
8
|
+
"Report-Msgid-Bugs-To: \n"
|
|
9
|
+
"Last-Translator: \n"
|
|
10
|
+
"Language-Team: \n"
|
|
11
|
+
"MIME-Version: 1.0\n"
|
|
12
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
|
13
|
+
"Content-Transfer-Encoding: \n"
|
|
14
|
+
"Plural-Forms: \n"
|
|
15
|
+
|
|
16
|
+
#. module: attachment_queue_email
|
|
17
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_attachment_queue__assigned_attachment_ids
|
|
18
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__assigned_attachment_ids
|
|
19
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_server__assigned_attachment_ids
|
|
20
|
+
msgid "Assigned Attachments"
|
|
21
|
+
msgstr ""
|
|
22
|
+
|
|
23
|
+
#. module: attachment_queue_email
|
|
24
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_server__attachment_condition_ids
|
|
25
|
+
msgid "Attachment Condition"
|
|
26
|
+
msgstr ""
|
|
27
|
+
|
|
28
|
+
#. module: attachment_queue_email
|
|
29
|
+
#: model_terms:ir.ui.view,arch_db:attachment_queue_email.view_fetchmail_attachment_condition_form
|
|
30
|
+
msgid "Attachment Condition requirements"
|
|
31
|
+
msgstr ""
|
|
32
|
+
|
|
33
|
+
#. module: attachment_queue_email
|
|
34
|
+
#: model_terms:ir.ui.view,arch_db:attachment_queue_email.view_email_server_form
|
|
35
|
+
msgid "Attachment Conditions"
|
|
36
|
+
msgstr ""
|
|
37
|
+
|
|
38
|
+
#. module: attachment_queue_email
|
|
39
|
+
#: model:ir.model,name:attachment_queue_email.model_attachment_queue
|
|
40
|
+
msgid "Attachment Queue"
|
|
41
|
+
msgstr ""
|
|
42
|
+
|
|
43
|
+
#. module: attachment_queue_email
|
|
44
|
+
#: model_terms:ir.ui.view,arch_db:attachment_queue_email.view_fetchmail_attachment_condition_form
|
|
45
|
+
msgid "Attachment process"
|
|
46
|
+
msgstr ""
|
|
47
|
+
|
|
48
|
+
#. module: attachment_queue_email
|
|
49
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__company_id
|
|
50
|
+
msgid "Company"
|
|
51
|
+
msgstr ""
|
|
52
|
+
|
|
53
|
+
#. module: attachment_queue_email
|
|
54
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__name
|
|
55
|
+
msgid "Condition Name"
|
|
56
|
+
msgstr ""
|
|
57
|
+
|
|
58
|
+
#. module: attachment_queue_email
|
|
59
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__create_uid
|
|
60
|
+
msgid "Created by"
|
|
61
|
+
msgstr ""
|
|
62
|
+
|
|
63
|
+
#. module: attachment_queue_email
|
|
64
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__create_date
|
|
65
|
+
msgid "Created on"
|
|
66
|
+
msgstr ""
|
|
67
|
+
|
|
68
|
+
#. module: attachment_queue_email
|
|
69
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__display_name
|
|
70
|
+
msgid "Display Name"
|
|
71
|
+
msgstr ""
|
|
72
|
+
|
|
73
|
+
#. module: attachment_queue_email
|
|
74
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__email_from
|
|
75
|
+
msgid "Email From"
|
|
76
|
+
msgstr ""
|
|
77
|
+
|
|
78
|
+
#. module: attachment_queue_email
|
|
79
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_attachment_queue__fetchmail_server_id
|
|
80
|
+
msgid "Email Server"
|
|
81
|
+
msgstr ""
|
|
82
|
+
|
|
83
|
+
#. module: attachment_queue_email
|
|
84
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__email_subject
|
|
85
|
+
msgid "Email Subject"
|
|
86
|
+
msgstr ""
|
|
87
|
+
|
|
88
|
+
#. module: attachment_queue_email
|
|
89
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__email_to
|
|
90
|
+
msgid "Email To"
|
|
91
|
+
msgstr ""
|
|
92
|
+
|
|
93
|
+
#. module: attachment_queue_email
|
|
94
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_attachment_queue__fetchmail_attachment_condition_id
|
|
95
|
+
msgid "FetchMail condition"
|
|
96
|
+
msgstr ""
|
|
97
|
+
|
|
98
|
+
#. module: attachment_queue_email
|
|
99
|
+
#: model:ir.model,name:attachment_queue_email.model_fetchmail_attachment_condition
|
|
100
|
+
msgid "Fetchmail Attachment Conditions"
|
|
101
|
+
msgstr ""
|
|
102
|
+
|
|
103
|
+
#. module: attachment_queue_email
|
|
104
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__file_extension
|
|
105
|
+
msgid "File Extension"
|
|
106
|
+
msgstr ""
|
|
107
|
+
|
|
108
|
+
#. module: attachment_queue_email
|
|
109
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__file_type
|
|
110
|
+
msgid "File Type"
|
|
111
|
+
msgstr ""
|
|
112
|
+
|
|
113
|
+
#. module: attachment_queue_email
|
|
114
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_fetchmail_server__attachment_condition_ids
|
|
115
|
+
msgid ""
|
|
116
|
+
"Files attached to the emails matching these conditions will be imported in "
|
|
117
|
+
"Odoo as 'Attachment Queue' objects"
|
|
118
|
+
msgstr ""
|
|
119
|
+
|
|
120
|
+
#. module: attachment_queue_email
|
|
121
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__id
|
|
122
|
+
msgid "ID"
|
|
123
|
+
msgstr ""
|
|
124
|
+
|
|
125
|
+
#. module: attachment_queue_email
|
|
126
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_fetchmail_attachment_condition__email_to
|
|
127
|
+
msgid ""
|
|
128
|
+
"If empty, catches the email no matter the recipient.\n"
|
|
129
|
+
"Otherwise catches the emails where the recipients emails contains the given characters."
|
|
130
|
+
msgstr ""
|
|
131
|
+
|
|
132
|
+
#. module: attachment_queue_email
|
|
133
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_fetchmail_attachment_condition__email_from
|
|
134
|
+
msgid ""
|
|
135
|
+
"If empty, catches the emails from every senders.\n"
|
|
136
|
+
"Otherwise catches the emails where the sender's email contains the given characters"
|
|
137
|
+
msgstr ""
|
|
138
|
+
|
|
139
|
+
#. module: attachment_queue_email
|
|
140
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_fetchmail_attachment_condition__email_subject
|
|
141
|
+
msgid ""
|
|
142
|
+
"If empty, catches the emails with every kind of Subjects.\n"
|
|
143
|
+
"Otherwise catches the emails where the Subject contains the given characters"
|
|
144
|
+
msgstr ""
|
|
145
|
+
|
|
146
|
+
#. module: attachment_queue_email
|
|
147
|
+
#: model:ir.model,name:attachment_queue_email.model_fetchmail_server
|
|
148
|
+
msgid "Incoming Mail Server"
|
|
149
|
+
msgstr ""
|
|
150
|
+
|
|
151
|
+
#. module: attachment_queue_email
|
|
152
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__write_uid
|
|
153
|
+
msgid "Last Updated by"
|
|
154
|
+
msgstr ""
|
|
155
|
+
|
|
156
|
+
#. module: attachment_queue_email
|
|
157
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__write_date
|
|
158
|
+
msgid "Last Updated on"
|
|
159
|
+
msgstr ""
|
|
160
|
+
|
|
161
|
+
#. module: attachment_queue_email
|
|
162
|
+
#: model_terms:ir.ui.view,arch_db:attachment_queue_email.view_fetchmail_attachment_condition_form
|
|
163
|
+
msgid "Requirements"
|
|
164
|
+
msgstr ""
|
|
165
|
+
|
|
166
|
+
#. module: attachment_queue_email
|
|
167
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__server_id
|
|
168
|
+
msgid "Server Mail"
|
|
169
|
+
msgstr ""
|
|
170
|
+
|
|
171
|
+
#. module: attachment_queue_email
|
|
172
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_attachment_queue__smart_search
|
|
173
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_attachment_condition__smart_search
|
|
174
|
+
#: model:ir.model.fields,field_description:attachment_queue_email.field_fetchmail_server__smart_search
|
|
175
|
+
msgid "Smart Search"
|
|
176
|
+
msgstr ""
|
|
177
|
+
|
|
178
|
+
#. module: attachment_queue_email
|
|
179
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_fetchmail_attachment_condition__file_type
|
|
180
|
+
msgid ""
|
|
181
|
+
"The 'file type' is transmited to the 'Attachment Queue' objects created from the selected emails attachments.\n"
|
|
182
|
+
"It will allow Odoo to recognize what do do with them once created."
|
|
183
|
+
msgstr ""
|
|
184
|
+
|
|
185
|
+
#. module: attachment_queue_email
|
|
186
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_attachment_queue__fetchmail_attachment_condition_id
|
|
187
|
+
msgid "The Fetchmail attachment condition used to create this attachment"
|
|
188
|
+
msgstr ""
|
|
189
|
+
|
|
190
|
+
#. module: attachment_queue_email
|
|
191
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_attachment_queue__fetchmail_server_id
|
|
192
|
+
msgid "The email server used to create this attachment"
|
|
193
|
+
msgstr ""
|
|
194
|
+
|
|
195
|
+
#. module: attachment_queue_email
|
|
196
|
+
#: model:ir.model.fields,help:attachment_queue_email.field_fetchmail_attachment_condition__file_extension
|
|
197
|
+
msgid ""
|
|
198
|
+
"The extension (or part of the name) of the sought files. If empty, all the "
|
|
199
|
+
"email's attachments will be imported."
|
|
200
|
+
msgstr ""
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Copyright 2012 Akretion (https://www.akretion.com).
|
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
|
3
|
+
|
|
4
|
+
import base64
|
|
5
|
+
|
|
6
|
+
from odoo import api, fields, models
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AttachmentQueue(models.Model):
|
|
10
|
+
_inherit = "attachment.queue"
|
|
11
|
+
|
|
12
|
+
fetchmail_attachment_condition_id = fields.Many2one(
|
|
13
|
+
"fetchmail.attachment.condition",
|
|
14
|
+
string="FetchMail condition",
|
|
15
|
+
help="The Fetchmail attachment condition used to create this attachment",
|
|
16
|
+
)
|
|
17
|
+
fetchmail_server_id = fields.Many2one(
|
|
18
|
+
"fetchmail.server",
|
|
19
|
+
string="Email Server",
|
|
20
|
+
related="fetchmail_attachment_condition_id.server_id",
|
|
21
|
+
store=True,
|
|
22
|
+
readonly=True,
|
|
23
|
+
help="The email server used to create this attachment",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
@api.model
|
|
27
|
+
def _get_attachment_queue_data(self, condition, msg, att):
|
|
28
|
+
data = att[1]
|
|
29
|
+
# seems files are byte when it comes from zip file so we manage
|
|
30
|
+
# both case
|
|
31
|
+
if isinstance(data, str):
|
|
32
|
+
data = data.encode()
|
|
33
|
+
values = {
|
|
34
|
+
"fetchmail_attachment_condition_id": condition.id,
|
|
35
|
+
"file_type": condition.file_type,
|
|
36
|
+
"name": att[0],
|
|
37
|
+
"datas": base64.b64encode(data),
|
|
38
|
+
"state": "pending",
|
|
39
|
+
"company_id": condition.company_id.id,
|
|
40
|
+
}
|
|
41
|
+
return values
|
|
42
|
+
|
|
43
|
+
@api.model
|
|
44
|
+
def prepare_data_from_basic_condition(self, cond, msg_dict):
|
|
45
|
+
vals_list = []
|
|
46
|
+
# match_from and match_subj are True if empty or if matching with
|
|
47
|
+
# msg_dict's values
|
|
48
|
+
match_from = (
|
|
49
|
+
cond.email_from
|
|
50
|
+
and cond.email_from in msg_dict.get("from", "")
|
|
51
|
+
or not cond.email_from
|
|
52
|
+
)
|
|
53
|
+
match_subj = (
|
|
54
|
+
cond.email_subject
|
|
55
|
+
and cond.email_subject in msg_dict.get("subject", "")
|
|
56
|
+
or not cond.email_subject
|
|
57
|
+
)
|
|
58
|
+
match_to = (
|
|
59
|
+
cond.email_to
|
|
60
|
+
and cond.email_to in msg_dict.get("to", "")
|
|
61
|
+
or not cond.email_to
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if match_from and match_subj and match_to:
|
|
65
|
+
for att in msg_dict["attachments"]:
|
|
66
|
+
if cond.file_extension in att[0] or not cond.file_extension:
|
|
67
|
+
vals_list.append(
|
|
68
|
+
self._get_attachment_queue_data(cond, msg_dict, att)
|
|
69
|
+
)
|
|
70
|
+
return vals_list
|
|
71
|
+
|
|
72
|
+
@api.model
|
|
73
|
+
def _prepare_data_for_attachment_queue(self, msg_dict):
|
|
74
|
+
"""Prepare the datas for the creation of one or many attachment.queue depending
|
|
75
|
+
on the number of the email's attachments files and if the email matches the
|
|
76
|
+
fetchmail.attachment.condition's conditions.
|
|
77
|
+
|
|
78
|
+
:param msg_dict: a dictionnary with the email data
|
|
79
|
+
:type: dict
|
|
80
|
+
|
|
81
|
+
:return: a list of dictionnary that contains the attachment.queue data
|
|
82
|
+
:rtype: list
|
|
83
|
+
"""
|
|
84
|
+
res = []
|
|
85
|
+
server_id = self.env.context.get("default_fetchmail_server_id", False)
|
|
86
|
+
file_condition_obj = self.env["fetchmail.attachment.condition"]
|
|
87
|
+
conds = file_condition_obj.search([("server_id", "=", server_id)])
|
|
88
|
+
for cond in conds:
|
|
89
|
+
vals_list = self.prepare_data_from_basic_condition(cond, msg_dict)
|
|
90
|
+
if vals_list:
|
|
91
|
+
res += vals_list
|
|
92
|
+
return res
|
|
93
|
+
|
|
94
|
+
@api.model
|
|
95
|
+
def message_new(self, msg_dict, custom_values=None):
|
|
96
|
+
"""Create Attachments Queues objects from the received email's attachments."""
|
|
97
|
+
# Rewriting completely ``message_new`` instead of overiding it in order to
|
|
98
|
+
# allows the creation of many new objects instead of only one.
|
|
99
|
+
created_recs = []
|
|
100
|
+
res = self._prepare_data_for_attachment_queue(msg_dict)
|
|
101
|
+
if res:
|
|
102
|
+
for vals in res:
|
|
103
|
+
created_recs.append(self.create(vals))
|
|
104
|
+
return created_recs[0]
|
|
105
|
+
return None
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Copyright 2012 Akretion (https://www.akretion.com).
|
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
|
3
|
+
|
|
4
|
+
from odoo import fields, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class FetchmailAttachmentCondition(models.Model):
|
|
8
|
+
_name = "fetchmail.attachment.condition"
|
|
9
|
+
_description = "Fetchmail Attachment Conditions"
|
|
10
|
+
|
|
11
|
+
name = fields.Char(
|
|
12
|
+
string="Condition Name",
|
|
13
|
+
required=True,
|
|
14
|
+
)
|
|
15
|
+
email_from = fields.Char(
|
|
16
|
+
help="If empty, catches the emails from every senders.\n"
|
|
17
|
+
"Otherwise catches the emails where the sender's email contains the given "
|
|
18
|
+
"characters",
|
|
19
|
+
)
|
|
20
|
+
email_to = fields.Char(
|
|
21
|
+
help="If empty, catches the email no matter the recipient.\n"
|
|
22
|
+
"Otherwise catches the emails where the recipients emails contains the given "
|
|
23
|
+
"characters.",
|
|
24
|
+
)
|
|
25
|
+
email_subject = fields.Char(
|
|
26
|
+
help="If empty, catches the emails with every kind of Subjects.\n"
|
|
27
|
+
"Otherwise catches the emails where the Subject contains the given characters",
|
|
28
|
+
)
|
|
29
|
+
file_extension = fields.Char(
|
|
30
|
+
help="The extension (or part of the name) of the sought files. "
|
|
31
|
+
"If empty, all the email's attachments will be imported.",
|
|
32
|
+
)
|
|
33
|
+
server_id = fields.Many2one("fetchmail.server", string="Server Mail")
|
|
34
|
+
file_type = fields.Selection(
|
|
35
|
+
selection=[],
|
|
36
|
+
help="The 'file type' is transmited to the 'Attachment Queue' objects created "
|
|
37
|
+
"from the selected emails attachments.\nIt will allow Odoo to recognize "
|
|
38
|
+
"what do do with them once created.",
|
|
39
|
+
)
|
|
40
|
+
company_id = fields.Many2one(
|
|
41
|
+
"res.company",
|
|
42
|
+
string="Company",
|
|
43
|
+
required=True,
|
|
44
|
+
default=lambda self: self.env.company,
|
|
45
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright 2012 Akretion (https://www.akretion.com).
|
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
|
3
|
+
|
|
4
|
+
from odoo import api, fields, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class FetchmailServer(models.Model):
|
|
8
|
+
_inherit = "fetchmail.server"
|
|
9
|
+
|
|
10
|
+
attachment_condition_ids = fields.One2many(
|
|
11
|
+
"fetchmail.attachment.condition",
|
|
12
|
+
"server_id",
|
|
13
|
+
string="Attachment Condition",
|
|
14
|
+
help="Files attached to the emails matching these conditions will be imported "
|
|
15
|
+
"in Odoo as 'Attachment Queue' objects",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
@api.onchange("attachment_condition_ids")
|
|
19
|
+
def onchange_attachment_condition(self):
|
|
20
|
+
for server in self:
|
|
21
|
+
if server.attachment_condition_ids:
|
|
22
|
+
server.object_id = self.env["ir.model"].search(
|
|
23
|
+
[("model", "=", "attachment.queue")]
|
|
24
|
+
)
|
|
25
|
+
server.attach = True
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Abstract module for importing emails attachments.
|
|
2
|
+
|
|
3
|
+
Each email's attachment matching a given **"Attachment Condition"** will
|
|
4
|
+
be imported creating a new `attachment.queue` object. These
|
|
5
|
+
`attachment.queue` objects are files wrapped with additional fields
|
|
6
|
+
(mainly a **Filed Type** and a **State**) making them ready to be
|
|
7
|
+
processed by a custom module as you can read in the
|
|
8
|
+
[attachment_queue](https://github.com/OCA/server-tools/tree/18.0/attachment_queue)
|
|
9
|
+
documentation.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Adding an **"Attachment Condition"** to your *Incoming Mail Server*
|
|
2
|
+
configuration will lead to the creation of `attachment.queue` objects
|
|
3
|
+
from emails attachments coming from this server and matching the given
|
|
4
|
+
*Attachment Condition*.
|
|
5
|
+
|
|
6
|
+
> 🔎 Recalling that, as the *Incoming Mail Servers* has only one
|
|
7
|
+
> *"Create a New Record"* field, the emails coming from that server
|
|
8
|
+
> **cannot be used to create other type of objects** than
|
|
9
|
+
> `attachment.queue`.
|
|
10
|
+
|
|
11
|
+
Filling the condition's **File Type** field will spread this value to
|
|
12
|
+
the newly created `attchment.queue` objects so they can be processed by
|
|
13
|
+
a custom module following this **File Type** field value.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
|
2
|
+
access_fetchmail_attachment_condition_manager,fetchmail.attachment.condition.manager,model_fetchmail_attachment_condition,base.group_system,1,1,1,1
|
|
3
|
+
access_fetchmail_attachment_condition_user,fetchmail.attachment.condition.user,model_fetchmail_attachment_condition,base.group_user,1,0,0,0
|
|
Binary file
|