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..aeb47ac6c0 100644 --- a/base_export_async/README.rst +++ b/base_export_async/README.rst @@ -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 ~~~~~~~~~~~ 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/migrations/12.0.1.1.0/post-migrate.py b/base_export_async/migrations/12.0.1.1.0/post-migrate.py new file mode 100644 index 0000000000..6ace97b1df --- /dev/null +++ b/base_export_async/migrations/12.0.1.1.0/post-migrate.py @@ -0,0 +1,23 @@ +# Copyright 2019 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import SUPERUSER_ID, api +from odoo.tools.sql import column_exists + + +def migrate(cr, version): + if not column_exists(cr, "delay_export", "__temp_user_id"): + return + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + field = env["delay.export"]._fields["user_ids"] + rel, id1, id2 = field.relation, field.column1, field.column2 + env.cr.execute( + """ + INSERT INTO %s (%s, %s) + SELECT id, __temp_user_id + FROM delay_export + """ + % (rel, id1, id2) + ) + env.cr.execute("ALTER TABLE delay_export DROP COLUMN __temp_user_id;") diff --git a/base_export_async/migrations/12.0.1.1.0/pre-migrate.py b/base_export_async/migrations/12.0.1.1.0/pre-migrate.py new file mode 100644 index 0000000000..51ca5be7bf --- /dev/null +++ b/base_export_async/migrations/12.0.1.1.0/pre-migrate.py @@ -0,0 +1,9 @@ +# Copyright 2019 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tools.sql import column_exists, rename_column + + +def migrate(cr, version): + if column_exists(cr, "delay_export", "user_id"): + rename_column(cr, "delay_export", "user_id", "__temp_user_id") diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py index 7881af001b..72121564a2 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 @@ -63,27 +62,36 @@ def _get_file_content(self, params): csv = CSVExport() return csv.from_data(columns_headers, import_data) else: - xls = ExcelExport() - return xls.from_data(columns_headers, import_data) + xlsx = ExcelExport() + return xlsx.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,37 +112,28 @@ 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 def cron_delete(self): - time_to_live = ( - self.env["ir.config_parameter"].sudo().get_param("attachment.ttl", 7) - ) date_today = fields.Date.today() - date_to_delete = date_today + relativedelta(days=-int(time_to_live)) - self.search([("create_date", "<=", date_to_delete)]).unlink() + self.search([("expiration_date", "<=", date_today)]).unlink() 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..a3b0940f19 100644 --- a/base_export_async/static/description/index.html +++ b/base_export_async/static/description/index.html @@ -408,7 +408,10 @@

Authors

Contributors

-

Arnaud Pineux (ACSONE SA/NV) authored the initial prototype.

+
    +
  • Arnaud Pineux (ACSONE SA/NV) authored the initial prototype.
  • +
  • Guewen Baconnier (Camptocamp)
  • +

Maintainers

diff --git a/base_export_async/static/src/js/data_export.js b/base_export_async/static/src/js/data_export.js index 06a7af02a0..0f3373ef25 100644 --- a/base_export_async/static/src/js/data_export.js +++ b/base_export_async/static/src/js/data_export.js @@ -1,11 +1,11 @@ -odoo.define('base_export_async.DataExport', function(require) { +odoo.define("base_export_async.DataExport", function (require) { "use strict"; - var core = require('web.core'); - var DataExport = require('web.DataExport'); - var framework = require('web.framework'); - var pyUtils = require('web.py_utils'); - var Dialog = require('web.Dialog'); + var core = require("web.core"); + var DataExport = require("web.DataExport"); + var framework = require("web.framework"); + var pyUtils = require("web.py_utils"); + var Dialog = require("web.Dialog"); var _t = core._t; DataExport.include({ @@ -14,83 +14,54 @@ odoo.define('base_export_async.DataExport', function(require) { A flag (checkbox) Async is added and if checked, call the delay export instead of the standard export. */ - start: function() { + start: function () { this._super.apply(this, arguments); - this.async = this.$('#async_export'); + this.async = this.$("#async_export"); }, - export_data: function() { - var self = this; - if (self.async.is(":checked")) { + _exportData(exportedFields, exportFormat, idsToExport) { + if (this.async.is(":checked")) { /* Checks from the standard method */ - var exported_fields = this.$( - '.o_fields_list option').map( - function() { - return { - name: (self.records[this.value] || - this).value, - label: this.textContent || - this.innerText - }; - }).get(); - - if (_.isEmpty(exported_fields)) { - Dialog.alert(this, _t( - "Please select fields to export..." - )); + if (_.isEmpty(exportedFields)) { + Dialog.alert(this, _t("Please select fields to export...")); return; } - if (!this.isCompatibleMode) { - exported_fields.unshift({ - name: 'id', - label: _t('External ID') - }); + if (this.isCompatibleMode) { + exportedFields.unshift({name: "id", label: _t("External ID")}); } - var export_format = this.$export_format_inputs - .filter(':checked').val(); - /* Call the delay export if Async is checked */ framework.blockUI(); this._rpc({ - model: 'delay.export', - method: 'delay_export', - args: [{ - data: JSON.stringify({ - format: export_format, - model: this - .record - .model, - fields: exported_fields, - ids: this - .ids_to_export, - domain: this - .domain, - context: pyUtils - .eval( - 'contexts', [ - this - .record - .getContext() - ] - ), - import_compat: - !! - this - .$import_compat_radios - .filter( - ':checked' - ).val(), - }) - }], - }).then(function(result) { + model: "delay.export", + method: "delay_export", + args: [ + { + data: JSON.stringify({ + format: exportFormat, + model: this.record.model, + fields: exportedFields, + ids: idsToExport, + domain: this.domain, + context: pyUtils.eval("contexts", [ + this.record.getContext(), + ]), + import_compat: this.isCompatibleMode, + user_ids: [this.record.context.uid], + }), + }, + ], + }).then(function () { framework.unblockUI(); - Dialog.alert(this, _t( - "You will receive the export file by email as soon as it is finished." - )); + Dialog.alert( + this, + _t( + "You will receive the export file by email as soon as it is finished." + ) + ); }); } else { /* diff --git a/base_export_async/static/src/xml/base.xml b/base_export_async/static/src/xml/base.xml index 24f53a000f..97b04cfeb1 100644 --- a/base_export_async/static/src/xml/base.xml +++ b/base_export_async/static/src/xml/base.xml @@ -1,12 +1,18 @@ - + - -
-