diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2530918092..a6cb1b5d61 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,6 @@ exclude: | (?x) # NOT INSTALLABLE ADDONS - ^base_export_async/| ^base_import_async/| ^test_base_import_async/| # END NOT INSTALLABLE ADDONS diff --git a/base_export_async/README.rst b/base_export_async/README.rst index 57652068e6..fad9c6b454 100644 --- a/base_export_async/README.rst +++ b/base_export_async/README.rst @@ -14,13 +14,13 @@ Base Export Async :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github - :target: https://github.com/OCA/queue/tree/12.0/base_export_async + :target: https://github.com/OCA/queue/tree/15.0/base_export_async :alt: OCA/queue .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/queue-12-0/queue-12-0-base_export_async + :target: https://translation.odoo-community.org/projects/queue-15-0/queue-15-0-base_export_async :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/230/12.0 + :target: https://runbot.odoo-community.org/runbot/230/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -35,8 +35,8 @@ Standard Export can be delayed in asynchronous jobs executed in the background a Usage ===== -The user is presented with a new checkbox "Asynchronous export" -in the export screen. When selected, the export is delayed in a +The user is presented with a new checkbox "Asynchronous export" +in the export screen. When selected, the export is delayed in a background job. The .csv or .xls file generated by the export will be sent by email @@ -48,7 +48,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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -63,7 +63,8 @@ Authors Contributors ~~~~~~~~~~~~ -Arnaud Pineux (ACSONE SA/NV) authored the initial prototype. +* Arnaud Pineux (ACSONE SA/NV) authored the initial prototype. +* Guewen Baconnier (Camptocamp) Maintainers ~~~~~~~~~~~ @@ -78,6 +79,6 @@ 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/queue `_ project on GitHub. +This module is part of the `OCA/queue `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_export_async/__manifest__.py b/base_export_async/__manifest__.py index a39844c499..90c68ec2d4 100644 --- a/base_export_async/__manifest__.py +++ b/base_export_async/__manifest__.py @@ -3,22 +3,27 @@ { "name": "Base Export Async", - "summary": """ - Asynchronous export with job queue - """, - "version": "12.0.1.0.0", + "summary": "Asynchronous export with job queue", + "version": "15.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/queue", "depends": ["web", "queue_job"], "data": [ - "views/assets.xml", "security/ir.model.access.csv", "security/ir_rule.xml", "data/config_parameter.xml", "data/cron.xml", + "data/mail_template.xml", ], "demo": [], - "qweb": ["static/src/xml/base.xml"], - "installable": False, + "assets": { + "web.assets_qweb": [ + "base_export_async/static/src/xml/base.xml", + ], + "web.assets_backend": [ + "base_export_async/static/src/js/data_export.js", + ], + }, + "installable": True, } diff --git a/base_export_async/data/config_parameter.xml b/base_export_async/data/config_parameter.xml index e3c1e5e35e..38ff75fd6e 100644 --- a/base_export_async/data/config_parameter.xml +++ b/base_export_async/data/config_parameter.xml @@ -1,4 +1,4 @@ - + attachment.ttl diff --git a/base_export_async/data/cron.xml b/base_export_async/data/cron.xml index ba42369ac3..7e12c92a02 100644 --- a/base_export_async/data/cron.xml +++ b/base_export_async/data/cron.xml @@ -1,8 +1,8 @@ - + Delete Generated Exports - + code model.cron_delete() 1 diff --git a/base_export_async/data/mail_template.xml b/base_export_async/data/mail_template.xml new file mode 100644 index 0000000000..18aaf926d8 --- /dev/null +++ b/base_export_async/data/mail_template.xml @@ -0,0 +1,26 @@ + + + + Delay Export + Export {{ object.model_description }} {{ datetime.date.today() }} + + + +

Your export is available here.

+

It will be automatically deleted the .

+
+

+ This is an automated message please do not reply. +

+
+
+
diff --git a/base_export_async/i18n/base_export_async.pot b/base_export_async/i18n/base_export_async.pot index 3f450bb117..dc3e413254 100644 --- a/base_export_async/i18n/base_export_async.pot +++ b/base_export_async/i18n/base_export_async.pot @@ -14,7 +14,7 @@ msgstr "" "Plural-Forms: \n" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:112 +#: code:addons/base_export_async/models/delay_export.py:129 #, python-format msgid "\n" "

Your export is available here.

\n" @@ -35,7 +35,7 @@ msgstr "" #. module: base_export_async #: model:ir.model,name:base_export_async.model_delay_export -msgid "Allow to delay the export" +msgid "Asynchronous Export" msgstr "" #. module: base_export_async @@ -68,7 +68,7 @@ msgid "Display Name" msgstr "" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:110 +#: code:addons/base_export_async/models/delay_export.py:127 #, python-format msgid "Export {} {}" msgstr "" @@ -108,25 +108,19 @@ msgid "Please select fields to export..." msgstr "" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:42 -#, python-format -msgid "The user doesn't have an email address." -msgstr "" - -#. module: base_export_async -#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_id -msgid "User" +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_ids +msgid "Users" msgstr "" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:29 +#: code:addons/base_export_async/models/delay_export.py:30 #, python-format msgid "You must set an email address to your user." msgstr "" #. module: base_export_async #. openerp-web -#: code:addons/base_export_async/static/src/js/data_export.js:91 +#: code:addons/base_export_async/static/src/js/data_export.js:92 #, python-format msgid "You will receive the export file by email as soon as it is finished." msgstr "" diff --git a/base_export_async/i18n/da.po b/base_export_async/i18n/da.po new file mode 100644 index 0000000000..3dc0d789ed --- /dev/null +++ b/base_export_async/i18n/da.po @@ -0,0 +1,137 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_export_async +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-02-07 17:45+0000\n" +"Last-Translator: Hans Henrik Gabelgaard \n" +"Language-Team: none\n" +"Language: da\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" +"X-Generator: Weblate 4.3.2\n" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:129 +#, python-format +msgid "\n" +"

Your export is available here.

\n" +"

It will be automatically deleted the {}.

\n" +"

 

\n" +"

\n" +" This is an automated message please do not reply.\n" +"

\n" +" " +msgstr "" +"\n" +"

Din export er tilgængelig her.

\n" +"

Den vil atutomatisk blive slettet den {}.

\n" +"

 

\n" +"

\n" +" Dette er en automatisk besked. Undlad venlisgt at besvare.\n" +"

\n" +" " + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "(You will receive the export by email)" +msgstr "(Du vil modtage eksporten via mail)" + +#. module: base_export_async +#: model:ir.model,name:base_export_async.model_delay_export +msgid "Asynchronous Export" +msgstr "Asynkron export" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "Asynchronous export" +msgstr "Asynkron export" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_uid +msgid "Created by" +msgstr "Oprettet af" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_date +msgid "Created on" +msgstr "Oprettet den" + +#. module: base_export_async +#: model:ir.actions.server,name:base_export_async.to_delete_attachment_ir_actions_server +#: model:ir.cron,cron_name:base_export_async.to_delete_attachment +#: model:ir.cron,name:base_export_async.to_delete_attachment +msgid "Delete Generated Exports" +msgstr "Slet genererede eksporter" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__display_name +msgid "Display Name" +msgstr "Vist navn" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:127 +#, python-format +msgid "Export {} {}" +msgstr "Eksport {} {}" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:47 +#, python-format +msgid "External ID" +msgstr "External ID" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__id +msgid "ID" +msgstr "ID" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export____last_update +msgid "Last Modified on" +msgstr "Senest rettet den" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_uid +msgid "Last Updated by" +msgstr "Senest rettet af" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_date +msgid "Last Updated on" +msgstr "Senest rettet den" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:39 +#, python-format +msgid "Please select fields to export..." +msgstr "Vælg venligst felter til eksporten..." + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_ids +msgid "Users" +msgstr "Brugere" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:30 +#, python-format +msgid "You must set an email address to your user." +msgstr "Du skal have en email adresse på dit brugeropsæt." + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:92 +#, python-format +msgid "You will receive the export file by email as soon as it is finished." +msgstr "Du vil modtage et link til eksporten så snart den er færdig." diff --git a/base_export_async/i18n/de.po b/base_export_async/i18n/de.po index 72d0bdfbc3..fec4ceff06 100644 --- a/base_export_async/i18n/de.po +++ b/base_export_async/i18n/de.po @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * base_export_async +# * base_export_async # msgid "" msgstr "" @@ -17,9 +17,10 @@ msgstr "" "X-Generator: Weblate 3.7.1\n" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:112 +#: code:addons/base_export_async/models/delay_export.py:129 #, python-format -msgid "\n" +msgid "" +"\n" "

Your export is available here.

\n" "

It will be automatically deleted the {}.

\n" "

 

\n" @@ -47,8 +48,9 @@ msgstr "(Der Export wird per Mail bereitgestellt.)" #. module: base_export_async #: model:ir.model,name:base_export_async.model_delay_export -msgid "Allow to delay the export" -msgstr "Verzögerung des Exports erlauben" +#, fuzzy +msgid "Asynchronous Export" +msgstr "Asynchroner Export" #. module: base_export_async #. openerp-web @@ -80,7 +82,7 @@ msgid "Display Name" msgstr "Anzeigename" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:110 +#: code:addons/base_export_async/models/delay_export.py:127 #, python-format msgid "Export {} {}" msgstr "Export {} {}" @@ -120,18 +122,12 @@ msgid "Please select fields to export..." msgstr "Bitte Felder für den Export auswählen..." #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:42 -#, python-format -msgid "The user doesn't have an email address." -msgstr "Der Benutzer hat keine Email-Adresse." - -#. module: base_export_async -#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_id -msgid "User" +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_ids +msgid "Users" msgstr "Benutzer" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:29 +#: code:addons/base_export_async/models/delay_export.py:30 #, python-format msgid "You must set an email address to your user." msgstr "" @@ -139,8 +135,14 @@ msgstr "" #. module: base_export_async #. openerp-web -#: code:addons/base_export_async/static/src/js/data_export.js:91 +#: code:addons/base_export_async/static/src/js/data_export.js:92 #, python-format msgid "You will receive the export file by email as soon as it is finished." msgstr "" "Die Export-Datei wird per Email versendet, sobald der Export beendet ist." + +#~ msgid "Allow to delay the export" +#~ msgstr "Verzögerung des Exports erlauben" + +#~ msgid "The user doesn't have an email address." +#~ msgstr "Der Benutzer hat keine Email-Adresse." diff --git a/base_export_async/i18n/fr.po b/base_export_async/i18n/fr.po new file mode 100644 index 0000000000..6884cb9e94 --- /dev/null +++ b/base_export_async/i18n/fr.po @@ -0,0 +1,137 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_export_async +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-11-20 16:54+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\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" +"X-Generator: Weblate 3.10\n" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:129 +#, python-format +msgid "\n" +"

Your export is available here.

\n" +"

It will be automatically deleted the {}.

\n" +"

 

\n" +"

\n" +" This is an automated message please do not reply.\n" +"

\n" +" " +msgstr "" +"\n" +"

Votre export est disponible ici.

\n" +"

Il sera automatiquement supprimé le {}.

\n" +"

 

\n" +"

\n" +" Ceci est un message automatisé, merci de ne pas répondre.\n" +"

\n" +" " + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "(You will receive the export by email)" +msgstr "(Vous recevrez cet export par courriel)" + +#. module: base_export_async +#: model:ir.model,name:base_export_async.model_delay_export +msgid "Asynchronous Export" +msgstr "Export asynchrone" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "Asynchronous export" +msgstr "Export asynchrone" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_date +msgid "Created on" +msgstr "Créé le" + +#. module: base_export_async +#: model:ir.actions.server,name:base_export_async.to_delete_attachment_ir_actions_server +#: model:ir.cron,cron_name:base_export_async.to_delete_attachment +#: model:ir.cron,name:base_export_async.to_delete_attachment +msgid "Delete Generated Exports" +msgstr "Supprimer les exports générés" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:127 +#, python-format +msgid "Export {} {}" +msgstr "Export {} {}" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:47 +#, python-format +msgid "External ID" +msgstr "Identifiant externe" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__id +msgid "ID" +msgstr "ID" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:39 +#, python-format +msgid "Please select fields to export..." +msgstr "Veuillez choisir les champs à exporter..." + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_ids +msgid "Users" +msgstr "Utilisateurs" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:30 +#, python-format +msgid "You must set an email address to your user." +msgstr "Vous devez définir une adresse e-mail pour votre utilisateur." + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:92 +#, python-format +msgid "You will receive the export file by email as soon as it is finished." +msgstr "Vous recevrez le fichier d'export par courriel dès qu'il sera terminé." diff --git a/base_export_async/i18n/it.po b/base_export_async/i18n/it.po new file mode 100644 index 0000000000..371d470376 --- /dev/null +++ b/base_export_async/i18n/it.po @@ -0,0 +1,127 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_export_async +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\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: base_export_async +#: code:addons/base_export_async/models/delay_export.py:129 +#, python-format +msgid "\n" +"

Your export is available here.

\n" +"

It will be automatically deleted the {}.

\n" +"

 

\n" +"

\n" +" This is an automated message please do not reply.\n" +"

\n" +" " +msgstr "" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "(You will receive the export by email)" +msgstr "" + +#. module: base_export_async +#: model:ir.model,name:base_export_async.model_delay_export +msgid "Asynchronous Export" +msgstr "" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "Asynchronous export" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_uid +msgid "Created by" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_date +msgid "Created on" +msgstr "" + +#. module: base_export_async +#: model:ir.actions.server,name:base_export_async.to_delete_attachment_ir_actions_server +#: model:ir.cron,cron_name:base_export_async.to_delete_attachment +#: model:ir.cron,name:base_export_async.to_delete_attachment +msgid "Delete Generated Exports" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__display_name +msgid "Display Name" +msgstr "" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:127 +#, python-format +msgid "Export {} {}" +msgstr "" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:47 +#, python-format +msgid "External ID" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__id +msgid "ID" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_date +msgid "Last Updated on" +msgstr "" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:39 +#, python-format +msgid "Please select fields to export..." +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_ids +msgid "Users" +msgstr "" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:30 +#, python-format +msgid "You must set an email address to your user." +msgstr "" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:92 +#, python-format +msgid "You will receive the export file by email as soon as it is finished." +msgstr "" diff --git a/base_export_async/i18n/pt.po b/base_export_async/i18n/pt.po new file mode 100644 index 0000000000..263957b21e --- /dev/null +++ b/base_export_async/i18n/pt.po @@ -0,0 +1,139 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_export_async +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-04 16:45+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\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" +"X-Generator: Weblate 4.3.2\n" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:129 +#, python-format +msgid "\n" +"

Your export is available here.

\n" +"

It will be automatically deleted the {}.

\n" +"

 

\n" +"

\n" +" This is an automated message please do not reply.\n" +"

\n" +" " +msgstr "" +"\n" +"

A sua exportação está disponível aqui.

\n" +"

Será automaticamente eliminada em {}.

\n" +"

 

\n" +"

\n" +" Esta é uma mensagem automática. Por favor, não responda.\n" +"

\n" +" " + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "(You will receive the export by email)" +msgstr "(Receberá a exportação por email)" + +#. module: base_export_async +#: model:ir.model,name:base_export_async.model_delay_export +msgid "Asynchronous Export" +msgstr "Exportação Assíncrona" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/xml/base.xml:9 +#, python-format +msgid "Asynchronous export" +msgstr "Exportação assíncrona" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_uid +msgid "Created by" +msgstr "Criada por" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_date +msgid "Created on" +msgstr "Criado em" + +#. module: base_export_async +#: model:ir.actions.server,name:base_export_async.to_delete_attachment_ir_actions_server +#: model:ir.cron,cron_name:base_export_async.to_delete_attachment +#: model:ir.cron,name:base_export_async.to_delete_attachment +msgid "Delete Generated Exports" +msgstr "Eliminar Exportações Geradas" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__display_name +msgid "Display Name" +msgstr "Nome a Apresentar" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:127 +#, python-format +msgid "Export {} {}" +msgstr "Exportar {} {}" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:47 +#, python-format +msgid "External ID" +msgstr "ID Externo" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__id +msgid "ID" +msgstr "" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export____last_update +msgid "Last Modified on" +msgstr "Última Modificação em" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_uid +msgid "Last Updated by" +msgstr "Última Atualização por" + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_date +msgid "Last Updated on" +msgstr "Última Atualização em" + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:39 +#, python-format +msgid "Please select fields to export..." +msgstr "Por favor, selecione os campos a exportar..." + +#. module: base_export_async +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_ids +msgid "Users" +msgstr "Utilizadores" + +#. module: base_export_async +#: code:addons/base_export_async/models/delay_export.py:30 +#, python-format +msgid "You must set an email address to your user." +msgstr "Tem que atribuir um email ao seu utilizador." + +#. module: base_export_async +#. openerp-web +#: code:addons/base_export_async/static/src/js/data_export.js:92 +#, python-format +msgid "You will receive the export file by email as soon as it is finished." +msgstr "" +"Receberá o ficheiro de exportação por email assim que este estiver terminado." diff --git a/base_export_async/i18n/zh_CN.po b/base_export_async/i18n/zh_CN.po index 356e6aac6a..3845e29031 100644 --- a/base_export_async/i18n/zh_CN.po +++ b/base_export_async/i18n/zh_CN.po @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * base_export_async +# * base_export_async # msgid "" msgstr "" @@ -17,9 +17,10 @@ msgstr "" "X-Generator: Weblate 3.7.1\n" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:112 +#: code:addons/base_export_async/models/delay_export.py:129 #, python-format -msgid "\n" +msgid "" +"\n" "

Your export is available here.

\n" "

It will be automatically deleted the {}.

\n" "

 

\n" @@ -46,8 +47,9 @@ msgstr "(您将通过电子邮件收到导出)" #. module: base_export_async #: model:ir.model,name:base_export_async.model_delay_export -msgid "Allow to delay the export" -msgstr "允许延迟导出" +#, fuzzy +msgid "Asynchronous Export" +msgstr "异步导出" #. module: base_export_async #. openerp-web @@ -79,7 +81,7 @@ msgid "Display Name" msgstr "显示名称" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:110 +#: code:addons/base_export_async/models/delay_export.py:127 #, python-format msgid "Export {} {}" msgstr "导出{} {}" @@ -119,25 +121,25 @@ msgid "Please select fields to export..." msgstr "请选择要导出的字段..." #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:42 -#, python-format -msgid "The user doesn't have an email address." -msgstr "用户没有电子邮件地址。" - -#. module: base_export_async -#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_id -msgid "User" +#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_ids +msgid "Users" msgstr "用户" #. module: base_export_async -#: code:addons/base_export_async/models/delay_export.py:29 +#: code:addons/base_export_async/models/delay_export.py:30 #, python-format msgid "You must set an email address to your user." msgstr "您必须为您的用户设置电子邮件地址。" #. module: base_export_async #. openerp-web -#: code:addons/base_export_async/static/src/js/data_export.js:91 +#: code:addons/base_export_async/static/src/js/data_export.js:92 #, python-format msgid "You will receive the export file by email as soon as it is finished." msgstr "完成后,您将通过电子邮件收到导出文件。" + +#~ msgid "Allow to delay the export" +#~ msgstr "允许延迟导出" + +#~ msgid "The user doesn't have an email address." +#~ msgstr "用户没有电子邮件地址。" diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py index 7881af001b..a4590df883 100644 --- a/base_export_async/models/delay_export.py +++ b/base_export_async/models/delay_export.py @@ -3,27 +3,29 @@ import base64 import json -import logging import operator from dateutil.relativedelta import relativedelta + from odoo import _, api, fields, models -from odoo.addons.queue_job.job import job -from odoo.addons.web.controllers.main import CSVExport, ExcelExport from odoo.exceptions import UserError -_logger = logging.getLogger(__name__) +from odoo.addons.web.controllers.main import CSVExport, ExcelExport class DelayExport(models.Model): _name = "delay.export" - _description = "Allow to delay the export" + _description = "Asynchronous Export" - user_id = fields.Many2one("res.users", string="User", index=True) + user_ids = fields.Many2many("res.users", string="Users", index=True) + model_description = fields.Char() + url = fields.Char() + expiration_date = fields.Date() @api.model def delay_export(self, data): + """Delay the export, called from js""" params = json.loads(data.get("data")) if not self.env.user.email: raise UserError(_("You must set an email address to your user.")) @@ -32,14 +34,11 @@ def delay_export(self, data): @api.model def _get_file_content(self, params): export_format = params.get("format") - raw_data = export_format != "csv" - item_names = ("model", "fields", "ids", "domain", "import_compat", "context") - items = operator.itemgetter(item_names)(params) - model_name, fields_name, ids, domain, import_compat, context = items - user = self.env["res.users"].browse([context.get("uid")]) - if not user or not user.email: - raise UserError(_("The user doesn't have an email address.")) + items = operator.itemgetter( + "model", "fields", "ids", "domain", "import_compat", "context", "user_ids" + )(params) + (model_name, fields_name, ids, domain, import_compat, context, user_ids) = items model = self.env[model_name].with_context( import_compat=import_compat, **context @@ -52,7 +51,7 @@ def _get_file_content(self, params): fields_name = [field for field in fields_name if field["name"] != "id"] field_names = [f["name"] for f in fields_name] - import_data = records.export_data(field_names, raw_data).get("datas", []) + import_data = records.export_data(field_names).get("datas", []) if import_compat: columns_headers = field_names @@ -67,23 +66,34 @@ def _get_file_content(self, params): return xls.from_data(columns_headers, import_data) @api.model - @job def export(self, params): + """Delayed export of a file sent by email + + The ``params`` is a dict of parameters, contains: + + * format: csv/excel + * model: model to export + * fields: list of fields to export, a list of dict: + [{'label': '', 'name': ''}] + * ids: list of ids to export + * domain: domain for the export + * context: context for the export (language, ...) + * import_compat: if the export is export/import compatible (boolean) + * user_ids: optional list of user ids who receive the file + """ content = self._get_file_content(params) - model_name, context, export_format = operator.itemgetter( - "model", "context", "format" - )(params) - user = self.env["res.users"].browse([context.get("uid")]) + items = operator.itemgetter("model", "context", "format", "user_ids")(params) + model_name, context, export_format, user_ids = items + users = self.env["res.users"].browse(user_ids) - export_record = self.sudo().create({"user_id": user.id}) + export_record = self.sudo().create({"user_ids": [(6, 0, users.ids)]}) name = "{}.{}".format(model_name, export_format) attachment = self.env["ir.attachment"].create( { "name": name, "datas": base64.b64encode(content), - "datas_fname": name, "type": "binary", "res_model": self._name, "res_id": export_record.id, @@ -104,30 +114,24 @@ def export(self, params): date_today + relativedelta(days=+int(time_to_live)) ) - # TODO : move to email template odoo_bot = self.sudo().env.ref("base.partner_root") email_from = odoo_bot.email model_description = self.env[model_name]._description - self.env["mail.mail"].create( + export_record.write( { + "url": url, + "expiration_date": expiration_date, + "model_description": model_description, + } + ) + + self.env.ref("base_export_async.delay_export_mail_template").send_mail( + export_record.id, + email_values={ "email_from": email_from, "reply_to": email_from, - "email_to": user.email, - "subject": _("Export {} {}").format( - model_description, fields.Date.to_string(fields.Date.today()) - ), - "body_html": _( - """ -

Your export is available here.

-

It will be automatically deleted the {}.

-

 

-

- This is an automated message please do not reply. -

- """ - ).format(url, expiration_date), - "auto_delete": True, - } + "recipient_ids": [(6, 0, users.mapped("partner_id").ids)], + }, ) @api.model diff --git a/base_export_async/readme/CONTRIBUTORS.rst b/base_export_async/readme/CONTRIBUTORS.rst index ede63fcc0d..b1a90f9127 100644 --- a/base_export_async/readme/CONTRIBUTORS.rst +++ b/base_export_async/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ -Arnaud Pineux (ACSONE SA/NV) authored the initial prototype. +* Arnaud Pineux (ACSONE SA/NV) authored the initial prototype. +* Guewen Baconnier (Camptocamp) diff --git a/base_export_async/security/ir_rule.xml b/base_export_async/security/ir_rule.xml index 7ed488ed37..d7934f09ae 100644 --- a/base_export_async/security/ir_rule.xml +++ b/base_export_async/security/ir_rule.xml @@ -1,13 +1,13 @@ - - + + Only user can read delay.export - - - - - - - [('user_id', '=', user.id)] + + + + + + + [('user_ids', 'in', user.id)] diff --git a/base_export_async/static/description/index.html b/base_export_async/static/description/index.html index 7620c7e958..74e3b5766a 100644 --- a/base_export_async/static/description/index.html +++ b/base_export_async/static/description/index.html @@ -3,7 +3,7 @@ - + Base Export Async