diff --git a/.travis.yml b/.travis.yml index 12862c09ad4..32cc8f140f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ install: - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - travis_install_nightly + - printf '[options]\n\nrunning_env = dev\n' > ${HOME}/.openerp_serverrc script: - travis_run_tests diff --git a/mail_cleanup/README.rst b/mail_cleanup/README.rst new file mode 100644 index 00000000000..b4efcdfb052 --- /dev/null +++ b/mail_cleanup/README.rst @@ -0,0 +1,98 @@ +============ +Mail cleanup +============ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/mail_cleanup + :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-mail_cleanup + :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| + +This module allows to: +---------------------- + +* mark e-mails older than x days as read, +* move those messages in a specific folder, +* remove messages older than x days + on IMAP servers, just before fetching them. + +Since the main "mail" module does not mark unroutable e-mails as read, +this means that if junk mail arrives in the catch-all address without +any default route, fetching newer e-mails will happen after re-parsing +those unroutable e-mails. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +This module depends on ``mail_environment`` in order to add "expiration dates" +per server. + +Example of a configuration file (add those values to your server):: + + [incoming_mail.openerp_imap_mail1] + cleanup_days = False # default value + purge_days = False # default value + cleanup_folder = NotParsed # optional parameter + +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 +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Matthieu Dietrich +* Artem Kostyuk + +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/mail_cleanup/__init__.py b/mail_cleanup/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/mail_cleanup/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_cleanup/__manifest__.py b/mail_cleanup/__manifest__.py new file mode 100644 index 00000000000..3b6dcc45805 --- /dev/null +++ b/mail_cleanup/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2015-2019 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + 'name': 'Mail cleanup', + 'version': '12.0.1.0.0', + 'category': 'Tools', + 'summary': 'Mark as read or delete mails after a set time', + 'author': 'Camptocamp, ' + 'Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'website': 'https://github.com/OCA/server-tools', + 'depends': [ + 'mail_environment', + ], + 'data': [ + 'views/mail_view.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/mail_cleanup/i18n/ca.po b/mail_cleanup/i18n/ca.po new file mode 100644 index 00000000000..0f4dd2fca16 --- /dev/null +++ b/mail_cleanup/i18n/ca.po @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# Marc Tormo i Bochaca , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-19 18:00+0000\n" +"PO-Revision-Date: 2017-04-19 18:00+0000\n" +"Last-Translator: Marc Tormo i Bochaca , 2017\n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "Servidor POP/IMAP" diff --git a/mail_cleanup/i18n/de.po b/mail_cleanup/i18n/de.po new file mode 100644 index 00000000000..774fecf5ce9 --- /dev/null +++ b/mail_cleanup/i18n/de.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# OCA Transbot , 2016 +# Rudolf Schnapka , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-19 18:00+0000\n" +"PO-Revision-Date: 2017-04-19 18:00+0000\n" +"Last-Translator: Rudolf Schnapka , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "Löschtage" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "Ablauftage" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "Ablauf-Ordner" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "Ordner, in den als gelesen gekennzeichnet Mail, verschoben wird." + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "Anzahl Tage bevor eine Nachricht als gelesen gekennzeichnet wird" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "POP/IMAP-Server" diff --git a/mail_cleanup/i18n/es.po b/mail_cleanup/i18n/es.po new file mode 100644 index 00000000000..147b4ba773a --- /dev/null +++ b/mail_cleanup/i18n/es.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# OCA Transbot , 2016 +# Pedro M. Baeza , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-17 02:07+0000\n" +"PO-Revision-Date: 2016-12-17 02:07+0000\n" +"Last-Translator: Pedro M. Baeza , 2016\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "Días para borrado" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "Días para expiración" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "Carpeta de expiración" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "Carpeta a la que serán movidos los correos marcados como leídos" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "Número de días antes de marcar un correo electrónico como leído" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "Número de días antes de eliminar un correo electrónico" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "Servidor POP/IMAP" diff --git a/mail_cleanup/i18n/fr.po b/mail_cleanup/i18n/fr.po new file mode 100644 index 00000000000..1b3e0d47b82 --- /dev/null +++ b/mail_cleanup/i18n/fr.po @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# Christophe CHAUVET , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:46+0000\n" +"PO-Revision-Date: 2016-11-26 01:46+0000\n" +"Last-Translator: Christophe CHAUVET , 2016\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "Serveur POP/IMAP" diff --git a/mail_cleanup/i18n/hr.po b/mail_cleanup/i18n/hr.po new file mode 100644 index 00000000000..bc43b14b216 --- /dev/null +++ b/mail_cleanup/i18n/hr.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# Bole , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:46+0000\n" +"PO-Revision-Date: 2016-11-26 01:46+0000\n" +"Last-Translator: Bole , 2016\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "POP/IMAP Server" diff --git a/mail_cleanup/i18n/it.po b/mail_cleanup/i18n/it.po new file mode 100644 index 00000000000..7854f72d8e3 --- /dev/null +++ b/mail_cleanup/i18n/it.po @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# Paolo Valier , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:46+0000\n" +"PO-Revision-Date: 2016-11-26 01:46+0000\n" +"Last-Translator: Paolo Valier , 2016\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "Server POP/IMAP" diff --git a/mail_cleanup/i18n/mail_cleanup.pot b/mail_cleanup/i18n/mail_cleanup.pot new file mode 100644 index 00000000000..14adb05d505 --- /dev/null +++ b/mail_cleanup/i18n/mail_cleanup.pot @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "" + diff --git a/mail_cleanup/i18n/pt_BR.po b/mail_cleanup/i18n/pt_BR.po new file mode 100644 index 00000000000..d6277017cbe --- /dev/null +++ b/mail_cleanup/i18n/pt_BR.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:46+0000\n" +"PO-Revision-Date: 2016-11-26 01:46+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "Servidor POP/IMAP" diff --git a/mail_cleanup/i18n/sl.po b/mail_cleanup/i18n/sl.po new file mode 100644 index 00000000000..f47332795c6 --- /dev/null +++ b/mail_cleanup/i18n/sl.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:46+0000\n" +"PO-Revision-Date: 2016-11-26 01:46+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "POP/IMAP strežnik" diff --git a/mail_cleanup/i18n/tr.po b/mail_cleanup/i18n/tr.po new file mode 100644 index 00000000000..0bada002567 --- /dev/null +++ b/mail_cleanup/i18n/tr.po @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# Ahmet Altinisik , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:46+0000\n" +"PO-Revision-Date: 2016-11-26 01:46+0000\n" +"Last-Translator: Ahmet Altinisik , 2016\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "POP/IMAP sunucu" diff --git a/mail_cleanup/i18n/zh_CN.po b/mail_cleanup/i18n/zh_CN.po new file mode 100644 index 00000000000..658b0e02946 --- /dev/null +++ b/mail_cleanup/i18n/zh_CN.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_cleanup +# +# Translators: +# Jeffery Chen Fan , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-26 01:46+0000\n" +"PO-Revision-Date: 2016-11-26 01:46+0000\n" +"Last-Translator: Jeffery Chen Fan , 2016\n" +"Language-Team: Chinese (China) (https://www.transifex.com/oca/teams/23907/" +"zh_CN/)\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_purge_days +msgid "Deletion days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Expiration days" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,field_description:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Expiration folder" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_folder +msgid "Folder where an e-mail marked as read will be moved." +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_cleanup_days +msgid "Number of days before marking an e-mail as read" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model.fields,help:mail_cleanup.field_fetchmail_server_purge_days +msgid "Number of days before removing an e-mail" +msgstr "" + +#. module: mail_cleanup +#: model:ir.model,name:mail_cleanup.model_fetchmail_server +msgid "POP/IMAP Server" +msgstr "POP/IMAP 服务器" diff --git a/mail_cleanup/models/__init__.py b/mail_cleanup/models/__init__.py new file mode 100644 index 00000000000..033e76401e1 --- /dev/null +++ b/mail_cleanup/models/__init__.py @@ -0,0 +1 @@ +from . import fetchmail_server diff --git a/mail_cleanup/models/fetchmail_server.py b/mail_cleanup/models/fetchmail_server.py new file mode 100644 index 00000000000..03c0a952b63 --- /dev/null +++ b/mail_cleanup/models/fetchmail_server.py @@ -0,0 +1,126 @@ +# Copyright 2015-2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging +import datetime + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models + +_logger = logging.getLogger(__name__) + + +class FetchmailServer(models.Model): + """Incoming POP/IMAP mail server account.""" + _inherit = 'fetchmail.server' + + cleanup_days = fields.Integer( + string='Expiration days', + help="Number of days before marking an e-mail as read", + ) + + cleanup_folder = fields.Char( + string='Expiration folder', + help="Folder where an e-mail marked as read will be moved.", + ) + + purge_days = fields.Integer( + string='Deletion days', + help="Number of days before removing an e-mail", + ) + + @property + def _server_env_fields(self): + base_fields = super()._server_env_fields + mail_cleanup_fields = { + 'cleanup_days': { + 'getter': 'getint', + }, + 'purge_days': { + 'getter': 'getint', + }, + 'cleanup_folder': {}, + } + mail_cleanup_fields.update(base_fields) + return mail_cleanup_fields + + def _cleanup_fetchmail_server(self, server, imap_server): + count, failed = 0, 0 + expiration_date = datetime.date.today() + expiration_date -= relativedelta(days=server.cleanup_days) + search_text = expiration_date.strftime('(UNSEEN BEFORE %d-%b-%Y)') + imap_server.select() + result, data = imap_server.search(None, search_text) + for num in data[0].split(): + try: + # Mark message as read + imap_server.store(num, '+FLAGS', '\\Seen') + if server.cleanup_folder: + # To move a message, you have to COPY + # then DELETE the message + result = imap_server.copy(num, server.cleanup_folder) + if result[0] == 'OK': + imap_server.store(num, '+FLAGS', '\\Deleted') + except Exception: + _logger.exception( + 'Failed to cleanup mail from %s server %s.', + server.type, server.name) + failed += 1 + count += 1 + _logger.info( + 'Marked %d email(s) as read on %s server %s;' + ' %d succeeded, %d failed.', count, server.type, + server.name, (count - failed), failed) + + def _purge_fetchmail_server(self, server, imap_server): + # Purging e-mails older than the purge date, if available + count, failed = 0, 0 + purge_date = datetime.date.today() + purge_date -= relativedelta(days=server.purge_days) + search_text = purge_date.strftime('(BEFORE %d-%b-%Y)') + imap_server.select() + result, data = imap_server.search(None, search_text) + for num in data[0].split(): + try: + # Delete message + imap_server.store(num, '+FLAGS', '\\Deleted') + except Exception: + _logger.exception( + 'Failed to remove mail from %s server %s.', + server.type, server.name) + failed += 1 + count += 1 + _logger.info( + 'Removed %d email(s) on %s server %s;' + ' %d succeeded, %d failed.', count, server.type, + server.name, (count - failed), failed) + + @api.multi + def fetch_mail(self): + # Called before the fetch, in order to clean up right before + # retrieving emails. + for server in self: + _logger.info('start cleaning up emails on %s server %s', + server.type, server.name) + imap_server = False + if server.type == 'imap': + try: + imap_server = server.connect() + if server.cleanup_days > 0: + self._cleanup_fetchmail_server(server, imap_server) + if server.purge_days > 0: + self._purge_fetchmail_server(server, imap_server) + # Do the final cleanup: delete all messages + # flagged as deleted + imap_server.expunge() + except Exception: + _logger.exception( + 'General failure when trying to cleanup' + ' mail from %s server %s.', + server.type, server.name) + finally: + if imap_server: + imap_server.close() + imap_server.logout() + return super().fetch_mail() diff --git a/mail_cleanup/readme/CONFIGURE.rst b/mail_cleanup/readme/CONFIGURE.rst new file mode 100644 index 00000000000..97b62955248 --- /dev/null +++ b/mail_cleanup/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +This module depends on ``mail_environment`` in order to add "expiration dates" +per server. + +Example of a configuration file (add those values to your server):: + + [incoming_mail.openerp_imap_mail1] + cleanup_days = False # default value + purge_days = False # default value + cleanup_folder = NotParsed # optional parameter diff --git a/mail_cleanup/readme/CONTRIBUTORS.rst b/mail_cleanup/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..99169ecc870 --- /dev/null +++ b/mail_cleanup/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Matthieu Dietrich +* Artem Kostyuk diff --git a/mail_cleanup/readme/DESCRIPTION.rst b/mail_cleanup/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..f70c430bf87 --- /dev/null +++ b/mail_cleanup/readme/DESCRIPTION.rst @@ -0,0 +1,12 @@ +This module allows to: +---------------------- + +* mark e-mails older than x days as read, +* move those messages in a specific folder, +* remove messages older than x days + on IMAP servers, just before fetching them. + +Since the main "mail" module does not mark unroutable e-mails as read, +this means that if junk mail arrives in the catch-all address without +any default route, fetching newer e-mails will happen after re-parsing +those unroutable e-mails. diff --git a/mail_cleanup/static/description/index.html b/mail_cleanup/static/description/index.html new file mode 100644 index 00000000000..a6056f3c432 --- /dev/null +++ b/mail_cleanup/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +Mail cleanup + + + +
+

Mail cleanup

+ + +

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

+
+

This module allows to:

+
    +
  • mark e-mails older than x days as read,
  • +
  • move those messages in a specific folder,
  • +
  • remove messages older than x days +on IMAP servers, just before fetching them.
  • +
+

Since the main “mail” module does not mark unroutable e-mails as read, +this means that if junk mail arrives in the catch-all address without +any default route, fetching newer e-mails will happen after re-parsing +those unroutable e-mails.

+

Table of contents

+ +
+

Configuration

+

This module depends on mail_environment in order to add “expiration dates” +per server.

+

Example of a configuration file (add those values to your server):

+
+[incoming_mail.openerp_imap_mail1]
+cleanup_days = False  # default value
+purge_days = False  # default value
+cleanup_folder = NotParsed  # optional parameter
+
+
+
+

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

+
    +
  • Camptocamp
  • +
+
+
+

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/mail_cleanup/views/mail_view.xml b/mail_cleanup/views/mail_view.xml new file mode 100644 index 00000000000..432c7a9c693 --- /dev/null +++ b/mail_cleanup/views/mail_view.xml @@ -0,0 +1,20 @@ + + + + + inherit_fetchmail_for cleanup + fetchmail.server + + + + + + + + + + + + + + diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 00000000000..0612c13e5d9 --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1 @@ +server-env