From 590c1db75cecfe8c4c48897b283da4d52b76959b Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 19 Apr 2019 11:52:10 +0200
Subject: [PATCH 01/60] [ADD] New module base_export_async to allow
asynchronous export
---
base_export_async/README.rst | 59 ++++++++++++
base_export_async/__init__.py | 4 +
base_export_async/__manifest__.py | 23 +++++
base_export_async/models/__init__.py | 4 +
base_export_async/models/delay_export.py | 85 ++++++++++++++++++
base_export_async/static/description/icon.png | Bin 0 -> 9455 bytes
.../static/src/js/data_export.js | 61 +++++++++++++
base_export_async/static/src/xml/base.xml | 15 ++++
base_export_async/views/assets.xml | 8 ++
9 files changed, 259 insertions(+)
create mode 100644 base_export_async/README.rst
create mode 100644 base_export_async/__init__.py
create mode 100644 base_export_async/__manifest__.py
create mode 100644 base_export_async/models/__init__.py
create mode 100644 base_export_async/models/delay_export.py
create mode 100644 base_export_async/static/description/icon.png
create mode 100644 base_export_async/static/src/js/data_export.js
create mode 100644 base_export_async/static/src/xml/base.xml
create mode 100644 base_export_async/views/assets.xml
diff --git a/base_export_async/README.rst b/base_export_async/README.rst
new file mode 100644
index 0000000000..d5b82fcfc0
--- /dev/null
+++ b/base_export_async/README.rst
@@ -0,0 +1,59 @@
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+
+=================
+Base Export Async
+=================
+
+Standard Export can be delayed in asynchronous jobs executed in the background and then send by email to the user.
+
+Configuration
+=============
+
+This module is using the Odoo Queue Modules.
+Please refer to that module for configuration.
+https://github.com/OCA/queue
+
+Usage
+=====
+
+During standard export, tick the "Asynchronous export" checkbox to make the export asynchronous.
+
+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 smash it by providing detailed and welcomed feedback.
+
+Credits
+=======
+
+Contributors
+------------
+
+* Pineux Arnaud
+
+Funders
+-------
+
+The development of this module has been financially supported by:
+
+* ACSONE SA/NV
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+This module is maintained by the OCA.
+
+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.
+
+To contribute to this module, please visit https://odoo-community.org.
diff --git a/base_export_async/__init__.py b/base_export_async/__init__.py
new file mode 100644
index 0000000000..8e4b46541f
--- /dev/null
+++ b/base_export_async/__init__.py
@@ -0,0 +1,4 @@
+# Copyright 2019 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from . import models
diff --git a/base_export_async/__manifest__.py b/base_export_async/__manifest__.py
new file mode 100644
index 0000000000..99ce1e7f4f
--- /dev/null
+++ b/base_export_async/__manifest__.py
@@ -0,0 +1,23 @@
+# Copyright 2019 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+{
+ 'name': 'Base Export Async',
+ 'summary': """
+ Asynchronous export with job queue
+ """,
+ 'version': '12.0.1.0.0',
+ 'license': 'AGPL-3',
+ 'author': 'ACSONE SA/NV, Odoo Community Association (OCA)',
+ 'website': 'https://acsone.eu/',
+ 'depends': [
+ 'web',
+ 'queue_job'
+ ],
+ 'data': [
+ 'views/assets.xml',
+ ],
+ 'demo': [
+ ],
+ 'qweb': ['static/src/xml/base.xml']
+}
diff --git a/base_export_async/models/__init__.py b/base_export_async/models/__init__.py
new file mode 100644
index 0000000000..f3652a9bf5
--- /dev/null
+++ b/base_export_async/models/__init__.py
@@ -0,0 +1,4 @@
+# Copyright 2019 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from . import delay_export
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
new file mode 100644
index 0000000000..033a1c5070
--- /dev/null
+++ b/base_export_async/models/delay_export.py
@@ -0,0 +1,85 @@
+# Copyright 2019 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+import logging
+import json
+import operator
+import base64
+
+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 Warning
+
+_logger = logging.getLogger(__name__)
+
+
+class DelayExport(models.Model):
+
+ _name = 'delay.export'
+ _description = 'Allow to delay the export'
+
+ @api.model
+ def delay_export(self, data):
+ params = json.loads(data.get('data'))
+ context = params.get('context', {})
+ uid = context.get('uid', False)
+ if not uid:
+ raise Warning(_("A problem occurs during the job creation. Please contact your administrator"))
+ user = self.env['res.users'].browse([uid])
+ if not user.email:
+ raise Warning(_("You must set an email address to your user."))
+ self.with_delay().export(params)
+
+ @api.model
+ @job
+ def export(self, params):
+ export_format = params.get('format')
+ raw_data = export_format != 'csv'
+
+ model_name, fields_name, ids, domain, import_compat, context = \
+ operator.itemgetter('model', 'fields', 'ids', 'domain', 'import_compat', 'context')(params)
+ user = self.env['res.users'].browse([context.get('uid')])
+ if not user or not user.email:
+ raise Warning(_("The user doesn't have an email address."))
+
+ model = self.env[model_name].with_context(import_compat=import_compat, **context)
+ records = model.browse(ids) or model.search(domain, offset=0, limit=False, order=False)
+
+ if not model._is_an_ordinary_table():
+ 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', [])
+
+ if import_compat:
+ columns_headers = field_names
+ else:
+ columns_headers = [val['label'].strip() for val in fields_name]
+
+ if export_format == 'csv':
+ csv = CSVExport()
+ result = csv.from_data(columns_headers, import_data)
+ else:
+ xls = ExcelExport()
+ result = xls.from_data(columns_headers, import_data)
+
+ attachment = self.env['ir.attachment'].create({
+ 'name': "{}.{}".format(model_name, export_format),
+ 'datas': base64.b64encode(result),
+ 'datas_fname': "{}.{}".format(model_name, export_format),
+ 'type': 'binary'
+ })
+
+ odoobot = self.env.ref("base.partner_root")
+ email_from = odoobot.email
+ self.env['mail.mail'].create({
+ 'email_from': email_from,
+ 'reply_to': email_from,
+ 'email_to': user.email,
+ 'subject': _("Export {} {}").format(model_name,
+ fields.Date.to_string(fields.Date.today())),
+ 'body_html': _("This is an automated message please do not reply."),
+ 'attachment_ids': [(4, attachment.id)],
+ 'auto_delete': True,
+ })
diff --git a/base_export_async/static/description/icon.png b/base_export_async/static/description/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d
GIT binary patch
literal 9455
zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~!
zVpnB`o+K7|Al`Q_U;eD$B
zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA
z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__
zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_
zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I
z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U
z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)(
z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH
zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW
z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB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6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k
z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp
z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{}
zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N
Xviia!U7SGha1wx#SCgwmn*{w2TRX*I
literal 0
HcmV?d00001
diff --git a/base_export_async/static/src/js/data_export.js b/base_export_async/static/src/js/data_export.js
new file mode 100644
index 0000000000..6368607628
--- /dev/null
+++ b/base_export_async/static/src/js/data_export.js
@@ -0,0 +1,61 @@
+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 _t = core._t;
+
+ DataExport.include({
+ start: function() {
+ this._super.apply(this, arguments);
+ this.async = this.$('#async_export');
+ },
+ export_data: function() {
+ var self = this;
+ if(self.async.is(":checked"))
+ {
+ 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..."));
+ return;
+ }
+ if (!this.isCompatibleMode) {
+ exported_fields.unshift({name: 'id', label: _t('External ID')});
+ }
+
+ var export_format = this.$export_format_inputs.filter(':checked').val();
+
+ 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) {
+ framework.unblockUI();
+ Dialog.alert(this, _t("You will receive the export file by email as soon as it is finished."));
+ });
+ } else {
+ this._super.apply(this, arguments);
+ }
+ },
+ });
+});
\ No newline at end of file
diff --git a/base_export_async/static/src/xml/base.xml b/base_export_async/static/src/xml/base.xml
new file mode 100644
index 0000000000..24f53a000f
--- /dev/null
+++ b/base_export_async/static/src/xml/base.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+ Asynchronous export (You will receive the export by email)
+
+
+
+
+
+
diff --git a/base_export_async/views/assets.xml b/base_export_async/views/assets.xml
new file mode 100644
index 0000000000..ae15a5ac64
--- /dev/null
+++ b/base_export_async/views/assets.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
From 04f194a7adb8a2ed7e0dc10cf13217be7fe07942 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 19 Apr 2019 13:51:54 +0200
Subject: [PATCH 02/60] [IMP] add ir.model.access
---
base_export_async/__manifest__.py | 1 +
base_export_async/security/ir.model.access.csv | 2 ++
2 files changed, 3 insertions(+)
create mode 100644 base_export_async/security/ir.model.access.csv
diff --git a/base_export_async/__manifest__.py b/base_export_async/__manifest__.py
index 99ce1e7f4f..b9acd7081e 100644
--- a/base_export_async/__manifest__.py
+++ b/base_export_async/__manifest__.py
@@ -16,6 +16,7 @@
],
'data': [
'views/assets.xml',
+ 'security/ir.model.access.csv',
],
'demo': [
],
diff --git a/base_export_async/security/ir.model.access.csv b/base_export_async/security/ir.model.access.csv
new file mode 100644
index 0000000000..7957cc9d7f
--- /dev/null
+++ b/base_export_async/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_delay_export,delay.export.user,model_delay_export,,1,1,1,1
\ No newline at end of file
From cf66c453709c7393647b1cf5243ac5b3629f8d79 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 19 Apr 2019 14:48:52 +0200
Subject: [PATCH 03/60] [IMP] PEP8 & JS
---
base_export_async/models/delay_export.py | 25 +++---
.../security/ir.model.access.csv | 2 +-
.../static/src/js/data_export.js | 78 +++++++++++++------
base_export_async/views/assets.xml | 2 +-
4 files changed, 71 insertions(+), 36 deletions(-)
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index 033a1c5070..3bafcc6b18 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -25,7 +25,8 @@ def delay_export(self, data):
context = params.get('context', {})
uid = context.get('uid', False)
if not uid:
- raise Warning(_("A problem occurs during the job creation. Please contact your administrator"))
+ raise Warning(_("A problem occurs during the job creation. \
+ Please contact your administrator"))
user = self.env['res.users'].browse([uid])
if not user.email:
raise Warning(_("You must set an email address to your user."))
@@ -38,19 +39,24 @@ def export(self, params):
raw_data = export_format != 'csv'
model_name, fields_name, ids, domain, import_compat, context = \
- operator.itemgetter('model', 'fields', 'ids', 'domain', 'import_compat', 'context')(params)
+ operator.itemgetter('model', 'fields', 'ids',
+ 'domain', 'import_compat', 'context')(params)
user = self.env['res.users'].browse([context.get('uid')])
if not user or not user.email:
raise Warning(_("The user doesn't have an email address."))
- model = self.env[model_name].with_context(import_compat=import_compat, **context)
- records = model.browse(ids) or model.search(domain, offset=0, limit=False, order=False)
+ model = self.env[model_name].with_context(
+ import_compat=import_compat, **context)
+ records = model.browse(ids) or model.search(
+ domain, offset=0, limit=False, order=False)
if not model._is_an_ordinary_table():
- fields_name = [field for field in fields_name if field['name'] != 'id']
+ 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, raw_data).get('datas', [])
if import_compat:
columns_headers = field_names
@@ -77,9 +83,10 @@ def export(self, params):
'email_from': email_from,
'reply_to': email_from,
'email_to': user.email,
- 'subject': _("Export {} {}").format(model_name,
- fields.Date.to_string(fields.Date.today())),
- 'body_html': _("This is an automated message please do not reply."),
+ 'subject': _("Export {} {}").format(
+ model_name, fields.Date.to_string(fields.Date.today())),
+ 'body_html': _("This is an automated \
+ message please do not reply."),
'attachment_ids': [(4, attachment.id)],
'auto_delete': True,
})
diff --git a/base_export_async/security/ir.model.access.csv b/base_export_async/security/ir.model.access.csv
index 7957cc9d7f..810456be20 100644
--- a/base_export_async/security/ir.model.access.csv
+++ b/base_export_async/security/ir.model.access.csv
@@ -1,2 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_delay_export,delay.export.user,model_delay_export,,1,1,1,1
\ No newline at end of file
+access_delay_export,delay.export.user,model_delay_export,,1,1,1,1
diff --git a/base_export_async/static/src/js/data_export.js b/base_export_async/static/src/js/data_export.js
index 6368607628..3a5cdc3898 100644
--- a/base_export_async/static/src/js/data_export.js
+++ b/base_export_async/static/src/js/data_export.js
@@ -1,5 +1,5 @@
-odoo.define('base_export_async.DataExport', function (require) {
-"use strict";
+odoo.define('base_export_async.DataExport', function(require) {
+ "use strict";
var core = require('web.core');
var DataExport = require('web.DataExport');
@@ -15,47 +15,75 @@ odoo.define('base_export_async.DataExport', function (require) {
},
export_data: function() {
var self = this;
- if(self.async.is(":checked"))
- {
- 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 (self.async.is(":checked")) {
+ 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..."));
+ Dialog.alert(this, _t(
+ "Please select fields to export..."
+ ));
return;
}
if (!this.isCompatibleMode) {
- exported_fields.unshift({name: 'id', label: _t('External ID')});
+ exported_fields.unshift({
+ name: 'id',
+ label: _t('External ID')
+ });
}
- var export_format = this.$export_format_inputs.filter(':checked').val();
+ var export_format = this.$export_format_inputs
+ .filter(':checked').val();
framework.blockUI();
this._rpc({
model: 'delay.export',
method: 'delay_export',
- args: [
- {data: JSON.stringify({
+ args: [{
+ data: JSON.stringify({
format: export_format,
- model: this.record.model,
+ 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) {
+ 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) {
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 {
this._super.apply(this, arguments);
}
},
});
-});
\ No newline at end of file
+});
diff --git a/base_export_async/views/assets.xml b/base_export_async/views/assets.xml
index ae15a5ac64..f0a778851c 100644
--- a/base_export_async/views/assets.xml
+++ b/base_export_async/views/assets.xml
@@ -5,4 +5,4 @@
-
\ No newline at end of file
+
From 7c4058c43a7eafdc553c0d7ae0888b795e398888 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 19 Apr 2019 16:07:01 +0200
Subject: [PATCH 04/60] [TEST] add test for base_export_async
---
base_export_async/tests/__init__.py | 4 ++
.../tests/test_base_export_async.py | 60 +++++++++++++++++++
2 files changed, 64 insertions(+)
create mode 100644 base_export_async/tests/__init__.py
create mode 100644 base_export_async/tests/test_base_export_async.py
diff --git a/base_export_async/tests/__init__.py b/base_export_async/tests/__init__.py
new file mode 100644
index 0000000000..ab60bd836f
--- /dev/null
+++ b/base_export_async/tests/__init__.py
@@ -0,0 +1,4 @@
+# Copyright 2019 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from . import test_base_export_async
diff --git a/base_export_async/tests/test_base_export_async.py b/base_export_async/tests/test_base_export_async.py
new file mode 100644
index 0000000000..a31782b420
--- /dev/null
+++ b/base_export_async/tests/test_base_export_async.py
@@ -0,0 +1,60 @@
+# Copyright 2019 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+import odoo.tests.common as common
+import json
+
+data_csv = {'data': """{"format": "csv", "model": "res.partner",
+ "fields": [{"name": "id", "label": "External ID"},
+ {"name": "display_name", "label": "Display Name"},
+ {"name": "email", "label": "Email"},
+ {"name": "phone", "label": "Phone"}],
+ "ids": false,
+ "domain": [],
+ "context": {"lang": "en_US", "tz": "Europe/Brussels", "uid": 2},
+ "import_compat": false}"""}
+
+data_xls = {'data': """{"format": "xls", "model": "res.partner",
+ "fields": [{"name": "id", "label": "External ID"},
+ {"name": "display_name", "label": "Display Name"},
+ {"name": "email", "label": "Email"},
+ {"name": "phone", "label": "Phone"}],
+ "ids": false,
+ "domain": [],
+ "context": {"lang": "en_US", "tz": "Europe/Brussels", "uid": 2},
+ "import_compat": false}"""}
+
+
+class TestBaseExportAsync(common.TransactionCase):
+
+ def setUp(self):
+ super(TestBaseExportAsync, self).setUp()
+ self.delay_export_obj = self.env['delay.export']
+ self.job_obj = self.env['queue.job']
+
+ def test_delay_export(self):
+ """ Check that the call create a new JOB"""
+ nbr_job = len(self.job_obj.search([]))
+ self.delay_export_obj.delay_export(data_csv)
+ new_nbr_job = len(self.job_obj.search([]))
+ self.assertEqual(new_nbr_job, nbr_job + 1)
+
+ def test_export_csv(self):
+ """ Check that the export generate an attachment and email"""
+ params = json.loads(data_csv.get('data'))
+ mails = self.env['mail.mail'].search([])
+ self.delay_export_obj.export(params)
+ new_mail = self.env['mail.mail'].search([]) - mails
+ self.assertEqual(len(new_mail), 1)
+ self.assertEqual(new_mail.attachment_ids[0].datas_fname,
+ "res.partner.csv")
+
+ def test_export_xls(self):
+ """ Check that the export generate an attachment and email"""
+ params = json.loads(data_xls.get('data'))
+ mails = self.env['mail.mail'].search([])
+ self.delay_export_obj.export(params)
+ new_mail = self.env['mail.mail'].search([]) - mails
+ self.assertEqual(len(new_mail), 1)
+ self.assertEqual(new_mail.attachment_ids[0].datas_fname,
+ "res.partner.xls")
From e2b1df798cf235508c80988ff97688944e779d21 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 19 Apr 2019 17:21:01 +0200
Subject: [PATCH 05/60] [IMP] get email from current user
---
base_export_async/models/delay_export.py | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index 3bafcc6b18..46da1907b5 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -22,13 +22,7 @@ class DelayExport(models.Model):
@api.model
def delay_export(self, data):
params = json.loads(data.get('data'))
- context = params.get('context', {})
- uid = context.get('uid', False)
- if not uid:
- raise Warning(_("A problem occurs during the job creation. \
- Please contact your administrator"))
- user = self.env['res.users'].browse([uid])
- if not user.email:
+ if not self.env.user.email:
raise Warning(_("You must set an email address to your user."))
self.with_delay().export(params)
From a3ef534466a7cd8ee6af0820a739d2c441f193d7 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Tue, 23 Apr 2019 09:47:37 +0200
Subject: [PATCH 06/60] [IMP] Generated Readme
---
base_export_async/README.rst | 76 ++--
base_export_async/readme/CONTRIBUTORS.rst | 1 +
base_export_async/readme/DESCRIPTION.rst | 1 +
base_export_async/readme/USAGE.rst | 6 +
.../static/description/index.html | 426 ++++++++++++++++++
5 files changed, 484 insertions(+), 26 deletions(-)
create mode 100644 base_export_async/readme/CONTRIBUTORS.rst
create mode 100644 base_export_async/readme/DESCRIPTION.rst
create mode 100644 base_export_async/readme/USAGE.rst
create mode 100644 base_export_async/static/description/index.html
diff --git a/base_export_async/README.rst b/base_export_async/README.rst
index d5b82fcfc0..57652068e6 100644
--- a/base_export_async/README.rst
+++ b/base_export_async/README.rst
@@ -1,59 +1,83 @@
-.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
- :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
- :alt: License: AGPL-3
-
=================
Base Export Async
=================
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! 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%2Fqueue-lightgray.png?logo=github
+ :target: https://github.com/OCA/queue/tree/12.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
+ :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
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
Standard Export can be delayed in asynchronous jobs executed in the background and then send by email to the user.
-Configuration
-=============
+**Table of contents**
-This module is using the Odoo Queue Modules.
-Please refer to that module for configuration.
-https://github.com/OCA/queue
+.. contents::
+ :local:
Usage
=====
-During standard export, tick the "Asynchronous export" checkbox to make the export asynchronous.
+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
+to the user who execute the export.
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 smash it by providing detailed and welcomed feedback.
+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
=======
-Contributors
-------------
+Authors
+~~~~~~~
-* Pineux Arnaud
+* ACSONE SA/NV
-Funders
--------
+Contributors
+~~~~~~~~~~~~
-The development of this module has been financially supported by:
+Arnaud Pineux (ACSONE SA/NV) authored the initial prototype.
-* ACSONE SA/NV
+Maintainers
+~~~~~~~~~~~
-Maintainer
-----------
+This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
-This module is maintained by the OCA.
-
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.
-To contribute to this module, please visit https://odoo-community.org.
+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/readme/CONTRIBUTORS.rst b/base_export_async/readme/CONTRIBUTORS.rst
new file mode 100644
index 0000000000..ede63fcc0d
--- /dev/null
+++ b/base_export_async/readme/CONTRIBUTORS.rst
@@ -0,0 +1 @@
+Arnaud Pineux (ACSONE SA/NV) authored the initial prototype.
diff --git a/base_export_async/readme/DESCRIPTION.rst b/base_export_async/readme/DESCRIPTION.rst
new file mode 100644
index 0000000000..91e212d4b3
--- /dev/null
+++ b/base_export_async/readme/DESCRIPTION.rst
@@ -0,0 +1 @@
+Standard Export can be delayed in asynchronous jobs executed in the background and then send by email to the user.
diff --git a/base_export_async/readme/USAGE.rst b/base_export_async/readme/USAGE.rst
new file mode 100644
index 0000000000..6bc2f841ba
--- /dev/null
+++ b/base_export_async/readme/USAGE.rst
@@ -0,0 +1,6 @@
+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
+to the user who execute the export.
diff --git a/base_export_async/static/description/index.html b/base_export_async/static/description/index.html
new file mode 100644
index 0000000000..6a727127d5
--- /dev/null
+++ b/base_export_async/static/description/index.html
@@ -0,0 +1,426 @@
+
+
+
+
+
+
+Base Export Async
+
+
+
+
+
Base Export Async
+
+
+
+
Standard Export can be delayed in asynchronous jobs executed in the background and then send by email to the user.
+
Table of contents
+
+
+
+
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
+to the user who execute the export.
+
+
+
+
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.
+
+
+
+
+
+
+
Arnaud Pineux (ACSONE SA/NV) authored the initial prototype.
+
+
+
+
This module is maintained by the OCA.
+
+
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.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute .
+
+
+
+
+
From 49f506e1ea654f76026a4e161cb1d97f83ef78f9 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Thu, 25 Apr 2019 09:56:29 +0200
Subject: [PATCH 07/60] [IMP] URL to attachment to avoid email size limit
---
base_export_async/__manifest__.py | 4 ++-
base_export_async/data/config_parameter.xml | 7 ++++
base_export_async/data/cron.xml | 12 +++++++
base_export_async/models/__init__.py | 1 +
base_export_async/models/attachment.py | 31 ++++++++++++++++++
base_export_async/models/delay_export.py | 36 ++++++++++++++++-----
6 files changed, 82 insertions(+), 9 deletions(-)
create mode 100644 base_export_async/data/config_parameter.xml
create mode 100644 base_export_async/data/cron.xml
create mode 100644 base_export_async/models/attachment.py
diff --git a/base_export_async/__manifest__.py b/base_export_async/__manifest__.py
index b9acd7081e..51fcfd2968 100644
--- a/base_export_async/__manifest__.py
+++ b/base_export_async/__manifest__.py
@@ -9,7 +9,7 @@
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'author': 'ACSONE SA/NV, Odoo Community Association (OCA)',
- 'website': 'https://acsone.eu/',
+ 'website': 'https://github.com/OCA/queue',
'depends': [
'web',
'queue_job'
@@ -17,6 +17,8 @@
'data': [
'views/assets.xml',
'security/ir.model.access.csv',
+ 'data/config_parameter.xml',
+ 'data/cron.xml',
],
'demo': [
],
diff --git a/base_export_async/data/config_parameter.xml b/base_export_async/data/config_parameter.xml
new file mode 100644
index 0000000000..83cb915c65
--- /dev/null
+++ b/base_export_async/data/config_parameter.xml
@@ -0,0 +1,7 @@
+
+
+
+ attachment.time.to.live
+ 7
+
+
diff --git a/base_export_async/data/cron.xml b/base_export_async/data/cron.xml
new file mode 100644
index 0000000000..63535dd18f
--- /dev/null
+++ b/base_export_async/data/cron.xml
@@ -0,0 +1,12 @@
+
+
+
+ Delete export generated attachment
+
+ code
+ model.cron_delete()
+ 1
+ days
+ -1
+
+
diff --git a/base_export_async/models/__init__.py b/base_export_async/models/__init__.py
index f3652a9bf5..e0aba64362 100644
--- a/base_export_async/models/__init__.py
+++ b/base_export_async/models/__init__.py
@@ -1,4 +1,5 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from . import attachment
from . import delay_export
diff --git a/base_export_async/models/attachment.py b/base_export_async/models/attachment.py
new file mode 100644
index 0000000000..b354c878db
--- /dev/null
+++ b/base_export_async/models/attachment.py
@@ -0,0 +1,31 @@
+# Copyright 2019 ACSONE SA/NV
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+from dateutil.relativedelta import relativedelta
+from odoo import api, models, fields
+
+
+class Attachment(models.Model):
+ _inherit = "ir.attachment"
+
+ to_delete = fields.Boolean(string="To delete by CRON", default=False)
+
+ @api.model_cr
+ def init(self):
+ self._cr.execute(
+ "SELECT indexname FROM pg_indexes WHERE "
+ "indexname = 'ir_attachment_to_delete_create_date'")
+ if not self._cr.fetchone():
+ self._cr.execute(
+ "CREATE INDEX ir_attachment_to_delete_create_date "
+ "ON ir_attachment (to_delete, create_date)")
+
+ @api.model
+ def cron_delete(self):
+ time_to_live = self.env.\
+ ref('base_export_async.attachment_time_to_live').value
+ date_today = fields.Date.from_string(fields.Date.today())
+ date_to_delete = fields.Date.to_string(
+ date_today + relativedelta(days=-int(time_to_live)))
+ self.search([('to_delete', '=', True),
+ ('create_date', '<=', date_to_delete)]).unlink()
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index 46da1907b5..e3413ba6ca 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -5,6 +5,7 @@
import json
import operator
import base64
+from dateutil.relativedelta import relativedelta
from odoo import api, fields, models, _
from odoo.addons.queue_job.job import job
@@ -64,23 +65,42 @@ def export(self, params):
xls = ExcelExport()
result = xls.from_data(columns_headers, import_data)
+ name = "{}.{}".format(model_name, export_format)
attachment = self.env['ir.attachment'].create({
- 'name': "{}.{}".format(model_name, export_format),
+ 'name': name,
'datas': base64.b64encode(result),
- 'datas_fname': "{}.{}".format(model_name, export_format),
- 'type': 'binary'
+ 'datas_fname': name,
+ 'type': 'binary',
+ 'to_delete': True,
})
- odoobot = self.env.ref("base.partner_root")
- email_from = odoobot.email
+ url = "{}/web/content/ir.attachment/{}/datas/{}?download=true".format(
+ self.env['ir.config_parameter'].sudo().get_param('web.base.url'),
+ attachment.id,
+ attachment.name,
+ )
+
+ time_to_live = self.env. \
+ ref('base_export_async.attachment_time_to_live').value
+ date_today = fields.Date.from_string(fields.Date.today())
+ expiration_date = fields.Date.to_string(
+ date_today + relativedelta(days=+int(time_to_live)))
+
+ odoo_bot = self.env.ref("base.partner_root")
+ email_from = odoo_bot.email
self.env['mail.mail'].create({
'email_from': email_from,
'reply_to': email_from,
'email_to': user.email,
'subject': _("Export {} {}").format(
model_name, fields.Date.to_string(fields.Date.today())),
- 'body_html': _("This is an automated \
- message please do not reply."),
- 'attachment_ids': [(4, attachment.id)],
+ '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,
})
From 39f8d1d875122df5201bd615e1e1973966dd6deb Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Thu, 25 Apr 2019 10:17:01 +0200
Subject: [PATCH 08/60] [TEST] Check that cron delete attachment after TTL
---
.../tests/test_base_export_async.py | 34 +++++++++++++++++--
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/base_export_async/tests/test_base_export_async.py b/base_export_async/tests/test_base_export_async.py
index a31782b420..6ba1996793 100644
--- a/base_export_async/tests/test_base_export_async.py
+++ b/base_export_async/tests/test_base_export_async.py
@@ -1,8 +1,11 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-import odoo.tests.common as common
import json
+from dateutil.relativedelta import relativedelta
+
+from odoo import fields
+import odoo.tests.common as common
data_csv = {'data': """{"format": "csv", "model": "res.partner",
"fields": [{"name": "id", "label": "External ID"},
@@ -43,18 +46,43 @@ def test_export_csv(self):
""" Check that the export generate an attachment and email"""
params = json.loads(data_csv.get('data'))
mails = self.env['mail.mail'].search([])
+ attachments = self.env['ir.attachment'].search([])
self.delay_export_obj.export(params)
new_mail = self.env['mail.mail'].search([]) - mails
+ new_attachment = self.env['ir.attachment'].search([]) - attachments
self.assertEqual(len(new_mail), 1)
- self.assertEqual(new_mail.attachment_ids[0].datas_fname,
+ self.assertEqual(new_attachment.datas_fname,
"res.partner.csv")
+ self.assertTrue(new_attachment.to_delete)
def test_export_xls(self):
""" Check that the export generate an attachment and email"""
params = json.loads(data_xls.get('data'))
mails = self.env['mail.mail'].search([])
+ attachments = self.env['ir.attachment'].search([])
self.delay_export_obj.export(params)
new_mail = self.env['mail.mail'].search([]) - mails
+ new_attachment = self.env['ir.attachment'].search([]) - attachments
self.assertEqual(len(new_mail), 1)
- self.assertEqual(new_mail.attachment_ids[0].datas_fname,
+ self.assertEqual(new_attachment.datas_fname,
"res.partner.xls")
+ self.assertTrue(new_attachment.to_delete)
+
+ def test_cron_delete(self):
+ """ Check that cron delete attachment after TTL"""
+ params = json.loads(data_csv.get('data'))
+ attachments = self.env['ir.attachment'].search([])
+ self.delay_export_obj.export(params)
+ new_attachment = self.env['ir.attachment'].search([]) - attachments
+ time_to_live = self.env. \
+ ref('base_export_async.attachment_time_to_live').value
+ date_today = fields.Date.from_string(fields.Date.today())
+ date_to_delete = fields.Date.to_string(
+ date_today + relativedelta(days=-int(time_to_live)))
+ # Update create_date with today - TTL
+ new_attachment.write({
+ 'create_date': date_to_delete
+ })
+ self.env['ir.attachment'].sudo().cron_delete()
+ # The attachment must be deleted
+ self.assertFalse(new_attachment.exists())
From 08c90cd0a447589f87ebdae75f9009839b4ad3f9 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Thu, 25 Apr 2019 15:07:50 +0200
Subject: [PATCH 09/60] [IMP] Improve security for the asynchronous export by
linking the attachment to a record only visible to the user
---
base_export_async/__manifest__.py | 1 +
base_export_async/data/cron.xml | 4 +--
base_export_async/models/__init__.py | 1 -
base_export_async/models/attachment.py | 31 -------------------
base_export_async/models/delay_export.py | 18 +++++++++--
.../security/ir.model.access.csv | 3 +-
base_export_async/security/ir_rule.xml | 13 ++++++++
.../tests/test_base_export_async.py | 6 ++--
8 files changed, 36 insertions(+), 41 deletions(-)
delete mode 100644 base_export_async/models/attachment.py
create mode 100644 base_export_async/security/ir_rule.xml
diff --git a/base_export_async/__manifest__.py b/base_export_async/__manifest__.py
index 51fcfd2968..7d82ffabdd 100644
--- a/base_export_async/__manifest__.py
+++ b/base_export_async/__manifest__.py
@@ -17,6 +17,7 @@
'data': [
'views/assets.xml',
'security/ir.model.access.csv',
+ 'security/ir_rule.xml',
'data/config_parameter.xml',
'data/cron.xml',
],
diff --git a/base_export_async/data/cron.xml b/base_export_async/data/cron.xml
index 63535dd18f..ba42369ac3 100644
--- a/base_export_async/data/cron.xml
+++ b/base_export_async/data/cron.xml
@@ -1,8 +1,8 @@
- Delete export generated attachment
-
+ Delete Generated Exports
+
code
model.cron_delete()
1
diff --git a/base_export_async/models/__init__.py b/base_export_async/models/__init__.py
index e0aba64362..f3652a9bf5 100644
--- a/base_export_async/models/__init__.py
+++ b/base_export_async/models/__init__.py
@@ -1,5 +1,4 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from . import attachment
from . import delay_export
diff --git a/base_export_async/models/attachment.py b/base_export_async/models/attachment.py
deleted file mode 100644
index b354c878db..0000000000
--- a/base_export_async/models/attachment.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2019 ACSONE SA/NV
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-
-from dateutil.relativedelta import relativedelta
-from odoo import api, models, fields
-
-
-class Attachment(models.Model):
- _inherit = "ir.attachment"
-
- to_delete = fields.Boolean(string="To delete by CRON", default=False)
-
- @api.model_cr
- def init(self):
- self._cr.execute(
- "SELECT indexname FROM pg_indexes WHERE "
- "indexname = 'ir_attachment_to_delete_create_date'")
- if not self._cr.fetchone():
- self._cr.execute(
- "CREATE INDEX ir_attachment_to_delete_create_date "
- "ON ir_attachment (to_delete, create_date)")
-
- @api.model
- def cron_delete(self):
- time_to_live = self.env.\
- ref('base_export_async.attachment_time_to_live').value
- date_today = fields.Date.from_string(fields.Date.today())
- date_to_delete = fields.Date.to_string(
- date_today + relativedelta(days=-int(time_to_live)))
- self.search([('to_delete', '=', True),
- ('create_date', '<=', date_to_delete)]).unlink()
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index e3413ba6ca..8ebb23ba73 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -20,6 +20,8 @@ class DelayExport(models.Model):
_name = 'delay.export'
_description = 'Allow to delay the export'
+ user_id = fields.Many2one('res.users', string='User', index=True)
+
@api.model
def delay_export(self, data):
params = json.loads(data.get('data'))
@@ -65,13 +67,16 @@ def export(self, params):
xls = ExcelExport()
result = xls.from_data(columns_headers, import_data)
+ export_record = self.sudo().create({'user_id': user.id})
+
name = "{}.{}".format(model_name, export_format)
attachment = self.env['ir.attachment'].create({
'name': name,
'datas': base64.b64encode(result),
'datas_fname': name,
'type': 'binary',
- 'to_delete': True,
+ 'res_model': self._name,
+ 'res_id': export_record.id,
})
url = "{}/web/content/ir.attachment/{}/datas/{}?download=true".format(
@@ -80,7 +85,7 @@ def export(self, params):
attachment.name,
)
- time_to_live = self.env. \
+ time_to_live = self.sudo().env. \
ref('base_export_async.attachment_time_to_live').value
date_today = fields.Date.from_string(fields.Date.today())
expiration_date = fields.Date.to_string(
@@ -104,3 +109,12 @@ def export(self, params):
""").format(url, expiration_date),
'auto_delete': True,
})
+
+ @api.model
+ def cron_delete(self):
+ time_to_live = self.env. \
+ ref('base_export_async.attachment_time_to_live').value
+ date_today = fields.Date.from_string(fields.Date.today())
+ date_to_delete = fields.Date.to_string(
+ date_today + relativedelta(days=-int(time_to_live)))
+ self.search([('create_date', '<=', date_to_delete)]).unlink()
diff --git a/base_export_async/security/ir.model.access.csv b/base_export_async/security/ir.model.access.csv
index 810456be20..948323af24 100644
--- a/base_export_async/security/ir.model.access.csv
+++ b/base_export_async/security/ir.model.access.csv
@@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_delay_export,delay.export.user,model_delay_export,,1,1,1,1
+access_delay_export,delay.export.user,model_delay_export,base.group_user,1,0,0,0
+access_delay_export_sudo,delay.export.sudo,model_delay_export,base.group_no_one,1,1,1,1
diff --git a/base_export_async/security/ir_rule.xml b/base_export_async/security/ir_rule.xml
new file mode 100644
index 0000000000..7ed488ed37
--- /dev/null
+++ b/base_export_async/security/ir_rule.xml
@@ -0,0 +1,13 @@
+
+
+
+ Only user can read delay.export
+
+
+
+
+
+
+ [('user_id', '=', user.id)]
+
+
diff --git a/base_export_async/tests/test_base_export_async.py b/base_export_async/tests/test_base_export_async.py
index 6ba1996793..66dd7a0846 100644
--- a/base_export_async/tests/test_base_export_async.py
+++ b/base_export_async/tests/test_base_export_async.py
@@ -53,7 +53,6 @@ def test_export_csv(self):
self.assertEqual(len(new_mail), 1)
self.assertEqual(new_attachment.datas_fname,
"res.partner.csv")
- self.assertTrue(new_attachment.to_delete)
def test_export_xls(self):
""" Check that the export generate an attachment and email"""
@@ -66,7 +65,6 @@ def test_export_xls(self):
self.assertEqual(len(new_mail), 1)
self.assertEqual(new_attachment.datas_fname,
"res.partner.xls")
- self.assertTrue(new_attachment.to_delete)
def test_cron_delete(self):
""" Check that cron delete attachment after TTL"""
@@ -80,9 +78,9 @@ def test_cron_delete(self):
date_to_delete = fields.Date.to_string(
date_today + relativedelta(days=-int(time_to_live)))
# Update create_date with today - TTL
- new_attachment.write({
+ self.delay_export_obj.search([]).write({
'create_date': date_to_delete
})
- self.env['ir.attachment'].sudo().cron_delete()
+ self.delay_export_obj.sudo().cron_delete()
# The attachment must be deleted
self.assertFalse(new_attachment.exists())
From 98da6c1c7176f4c45717b21469d7d5b5c1a33d63 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Thu, 25 Apr 2019 16:05:58 +0200
Subject: [PATCH 10/60] [IMP] Improve the use of dates and config_parameter
---
base_export_async/data/config_parameter.xml | 2 +-
base_export_async/models/delay_export.py | 11 +++++------
base_export_async/tests/test_base_export_async.py | 9 ++++-----
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/base_export_async/data/config_parameter.xml b/base_export_async/data/config_parameter.xml
index 83cb915c65..1a2d4ae383 100644
--- a/base_export_async/data/config_parameter.xml
+++ b/base_export_async/data/config_parameter.xml
@@ -1,5 +1,5 @@
-
+
attachment.time.to.live
7
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index 8ebb23ba73..af95f89560 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -85,9 +85,9 @@ def export(self, params):
attachment.name,
)
- time_to_live = self.sudo().env. \
- ref('base_export_async.attachment_time_to_live').value
- date_today = fields.Date.from_string(fields.Date.today())
+ time_to_live = self.env['ir.config_parameter'].sudo(). \
+ get_param('attachment.time.to.live', 7)
+ date_today = fields.Date.today()
expiration_date = fields.Date.to_string(
date_today + relativedelta(days=+int(time_to_live)))
@@ -114,7 +114,6 @@ def export(self, params):
def cron_delete(self):
time_to_live = self.env. \
ref('base_export_async.attachment_time_to_live').value
- date_today = fields.Date.from_string(fields.Date.today())
- date_to_delete = fields.Date.to_string(
- date_today + relativedelta(days=-int(time_to_live)))
+ date_today = fields.Date.today()
+ date_to_delete = date_today + relativedelta(days=-int(time_to_live))
self.search([('create_date', '<=', date_to_delete)]).unlink()
diff --git a/base_export_async/tests/test_base_export_async.py b/base_export_async/tests/test_base_export_async.py
index 66dd7a0846..1b7b508dcb 100644
--- a/base_export_async/tests/test_base_export_async.py
+++ b/base_export_async/tests/test_base_export_async.py
@@ -72,11 +72,10 @@ def test_cron_delete(self):
attachments = self.env['ir.attachment'].search([])
self.delay_export_obj.export(params)
new_attachment = self.env['ir.attachment'].search([]) - attachments
- time_to_live = self.env. \
- ref('base_export_async.attachment_time_to_live').value
- date_today = fields.Date.from_string(fields.Date.today())
- date_to_delete = fields.Date.to_string(
- date_today + relativedelta(days=-int(time_to_live)))
+ time_to_live = self.env['ir.config_parameter'].sudo(). \
+ get_param('attachment.time.to.live', 7)
+ date_today = fields.Date.today()
+ date_to_delete = date_today + relativedelta(days=-int(time_to_live))
# Update create_date with today - TTL
self.delay_export_obj.search([]).write({
'create_date': date_to_delete
From 20153b2d1829ad9246f275a8732a089ee54037ab Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Tue, 30 Apr 2019 09:00:51 +0200
Subject: [PATCH 11/60] [FIX] Can read odoobot email address
---
base_export_async/models/delay_export.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index af95f89560..0c8fb4580d 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -91,7 +91,7 @@ def export(self, params):
expiration_date = fields.Date.to_string(
date_today + relativedelta(days=+int(time_to_live)))
- odoo_bot = self.env.ref("base.partner_root")
+ odoo_bot = self.sudo().env.ref("base.partner_root")
email_from = odoo_bot.email
self.env['mail.mail'].create({
'email_from': email_from,
From 35383ada3bf62b426b933c8605597be1ff67eee3 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Tue, 30 Apr 2019 13:34:25 +0200
Subject: [PATCH 12/60] [IMP] Change Warning by UserError
---
base_export_async/models/delay_export.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index 0c8fb4580d..786d5b0bbc 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -10,7 +10,7 @@
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 Warning
+from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@@ -26,7 +26,7 @@ class DelayExport(models.Model):
def delay_export(self, data):
params = json.loads(data.get('data'))
if not self.env.user.email:
- raise Warning(_("You must set an email address to your user."))
+ raise UserError(_("You must set an email address to your user."))
self.with_delay().export(params)
@api.model
@@ -40,7 +40,7 @@ def export(self, params):
'domain', 'import_compat', 'context')(params)
user = self.env['res.users'].browse([context.get('uid')])
if not user or not user.email:
- raise Warning(_("The user doesn't have an email address."))
+ raise UserError(_("The user doesn't have an email address."))
model = self.env[model_name].with_context(
import_compat=import_compat, **context)
From 93d735d873cfbbf0bfd213d8a22b023a89f35c6c Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 24 May 2019 12:06:19 +0200
Subject: [PATCH 13/60] [IMP] Improve naming
---
base_export_async/data/config_parameter.xml | 4 ++--
base_export_async/models/delay_export.py | 7 ++++---
base_export_async/tests/test_base_export_async.py | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/base_export_async/data/config_parameter.xml b/base_export_async/data/config_parameter.xml
index 1a2d4ae383..e3c1e5e35e 100644
--- a/base_export_async/data/config_parameter.xml
+++ b/base_export_async/data/config_parameter.xml
@@ -1,7 +1,7 @@
-
- attachment.time.to.live
+
+ attachment.ttl
7
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index 786d5b0bbc..e12ea724b3 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -86,11 +86,12 @@ def export(self, params):
)
time_to_live = self.env['ir.config_parameter'].sudo(). \
- get_param('attachment.time.to.live', 7)
+ get_param('attachment.ttl', 7)
date_today = fields.Date.today()
expiration_date = fields.Date.to_string(
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
self.env['mail.mail'].create({
@@ -112,8 +113,8 @@ def export(self, params):
@api.model
def cron_delete(self):
- time_to_live = self.env. \
- ref('base_export_async.attachment_time_to_live').value
+ 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()
diff --git a/base_export_async/tests/test_base_export_async.py b/base_export_async/tests/test_base_export_async.py
index 1b7b508dcb..a9c589ecbc 100644
--- a/base_export_async/tests/test_base_export_async.py
+++ b/base_export_async/tests/test_base_export_async.py
@@ -73,7 +73,7 @@ def test_cron_delete(self):
self.delay_export_obj.export(params)
new_attachment = self.env['ir.attachment'].search([]) - attachments
time_to_live = self.env['ir.config_parameter'].sudo(). \
- get_param('attachment.time.to.live', 7)
+ get_param('attachment.ttl', 7)
date_today = fields.Date.today()
date_to_delete = date_today + relativedelta(days=-int(time_to_live))
# Update create_date with today - TTL
From 5f551c8536edc4e45f46380ddd4b618611bec93f Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Fri, 24 May 2019 14:42:44 +0200
Subject: [PATCH 14/60] [IMP] Split method + comments
---
base_export_async/models/delay_export.py | 18 +++++++++++++-----
base_export_async/static/src/js/data_export.js | 14 ++++++++++++++
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index e12ea724b3..d1ebfa2ff6 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -30,8 +30,7 @@ def delay_export(self, data):
self.with_delay().export(params)
@api.model
- @job
- def export(self, params):
+ def _get_file_content(self, params):
export_format = params.get('format')
raw_data = export_format != 'csv'
@@ -62,17 +61,26 @@ def export(self, params):
if export_format == 'csv':
csv = CSVExport()
- result = csv.from_data(columns_headers, import_data)
+ return csv.from_data(columns_headers, import_data)
else:
xls = ExcelExport()
- result = xls.from_data(columns_headers, import_data)
+ return xls.from_data(columns_headers, import_data)
+
+ @api.model
+ @job
+ def export(self, params):
+ 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')])
export_record = self.sudo().create({'user_id': user.id})
name = "{}.{}".format(model_name, export_format)
attachment = self.env['ir.attachment'].create({
'name': name,
- 'datas': base64.b64encode(result),
+ 'datas': base64.b64encode(content),
'datas_fname': name,
'type': 'binary',
'res_model': self._name,
diff --git a/base_export_async/static/src/js/data_export.js b/base_export_async/static/src/js/data_export.js
index 3a5cdc3898..06a7af02a0 100644
--- a/base_export_async/static/src/js/data_export.js
+++ b/base_export_async/static/src/js/data_export.js
@@ -9,6 +9,11 @@ odoo.define('base_export_async.DataExport', function(require) {
var _t = core._t;
DataExport.include({
+ /*
+ Overwritten Object responsible for the standard export.
+ A flag (checkbox) Async is added and if checked, call the
+ delay export instead of the standard export.
+ */
start: function() {
this._super.apply(this, arguments);
this.async = this.$('#async_export');
@@ -16,6 +21,9 @@ odoo.define('base_export_async.DataExport', function(require) {
export_data: function() {
var self = this;
if (self.async.is(":checked")) {
+ /*
+ Checks from the standard method
+ */
var exported_fields = this.$(
'.o_fields_list option').map(
function() {
@@ -43,6 +51,9 @@ odoo.define('base_export_async.DataExport', function(require) {
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',
@@ -82,6 +93,9 @@ odoo.define('base_export_async.DataExport', function(require) {
));
});
} else {
+ /*
+ Call the standard method if Async is not checked
+ */
this._super.apply(this, arguments);
}
},
From 6c28b5256aa828a47d1ce08cb040af7e1bd61745 Mon Sep 17 00:00:00 2001
From: Arnaud Pineux
Date: Wed, 19 Jun 2019 15:29:12 +0200
Subject: [PATCH 15/60] [IMP] Add the model description instead of name on the
email subject
---
base_export_async/models/delay_export.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/base_export_async/models/delay_export.py b/base_export_async/models/delay_export.py
index d1ebfa2ff6..925ee88b34 100644
--- a/base_export_async/models/delay_export.py
+++ b/base_export_async/models/delay_export.py
@@ -102,12 +102,13 @@ def export(self, params):
# 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({
'email_from': email_from,
'reply_to': email_from,
'email_to': user.email,
'subject': _("Export {} {}").format(
- model_name, fields.Date.to_string(fields.Date.today())),
+ model_description, fields.Date.to_string(fields.Date.today())),
'body_html': _("""
Your export is available here .
It will be automatically deleted the {}.
From cea72ffc5ff393cc3adad812dda74fcb0bd16d71 Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Fri, 21 Jun 2019 09:46:57 +0000
Subject: [PATCH 16/60] [UPD] Update base_export_async.pot
---
base_export_async/i18n/base_export_async.pot | 133 +++++++++++++++++++
1 file changed, 133 insertions(+)
create mode 100644 base_export_async/i18n/base_export_async.pot
diff --git a/base_export_async/i18n/base_export_async.pot b/base_export_async/i18n/base_export_async.pot
new file mode 100644
index 0000000000..3f450bb117
--- /dev/null
+++ b/base_export_async/i18n/base_export_async.pot
@@ -0,0 +1,133 @@
+# 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: <>\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: base_export_async
+#: code:addons/base_export_async/models/delay_export.py:112
+#, 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 "Allow to delay the 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:110
+#, 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
+#: 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"
+msgstr ""
+
+#. module: base_export_async
+#: code:addons/base_export_async/models/delay_export.py:29
+#, 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
+#, python-format
+msgid "You will receive the export file by email as soon as it is finished."
+msgstr ""
+
From 010348d5e69162e9ac93dd923aee1fc988073102 Mon Sep 17 00:00:00 2001
From: Maria Sparenberg
Date: Thu, 4 Jul 2019 12:15:22 +0000
Subject: [PATCH 17/60] Added translation using Weblate (German)
---
base_export_async/i18n/de.po | 133 +++++++++++++++++++++++++++++++++++
1 file changed, 133 insertions(+)
create mode 100644 base_export_async/i18n/de.po
diff --git a/base_export_async/i18n/de.po b/base_export_async/i18n/de.po
new file mode 100644
index 0000000000..883bf72944
--- /dev/null
+++ b/base_export_async/i18n/de.po
@@ -0,0 +1,133 @@
+# 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: 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: base_export_async
+#: code:addons/base_export_async/models/delay_export.py:112
+#, 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 "Allow to delay the 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:110
+#, 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
+#: 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"
+msgstr ""
+
+#. module: base_export_async
+#: code:addons/base_export_async/models/delay_export.py:29
+#, 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
+#, python-format
+msgid "You will receive the export file by email as soon as it is finished."
+msgstr ""
From ffa29e44b0641ba72936a37e8d12cf0a6fbebab3 Mon Sep 17 00:00:00 2001
From: Maria Sparenberg
Date: Thu, 4 Jul 2019 12:17:52 +0000
Subject: [PATCH 18/60] Translated using Weblate (German)
Currently translated at 100.0% (19 of 19 strings)
Translation: queue-12.0/queue-12.0-base_export_async
Translate-URL: https://translation.odoo-community.org/projects/queue-12-0/queue-12-0-base_export_async/de/
---
base_export_async/i18n/de.po | 47 +++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/base_export_async/i18n/de.po b/base_export_async/i18n/de.po
index 883bf72944..72d0bdfbc3 100644
--- a/base_export_async/i18n/de.po
+++ b/base_export_async/i18n/de.po
@@ -6,13 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2019-07-04 14:43+0000\n"
+"Last-Translator: Maria Sparenberg \n"
"Language-Team: none\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"
+"X-Generator: Weblate 3.7.1\n"
#. module: base_export_async
#: code:addons/base_export_async/models/delay_export.py:112
@@ -26,104 +28,114 @@ msgid "\n"
"
\n"
" "
msgstr ""
+"\n"
+" Der Export ist hier verfügbar.
\n"
+" Das {} wird automatisch gelöscht.
\n"
+"
\n"
+" \n"
+" Dies ist eine automatisch erstellte Nachricht, bitte nicht "
+"darauf antworten.\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 ""
+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 ""
+msgstr "Verzögerung des Exports erlauben"
#. module: base_export_async
#. openerp-web
#: code:addons/base_export_async/static/src/xml/base.xml:9
#, python-format
msgid "Asynchronous export"
-msgstr ""
+msgstr "Asynchroner Export"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_uid
msgid "Created by"
-msgstr ""
+msgstr "Erstellt von"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_date
msgid "Created on"
-msgstr ""
+msgstr "Erstellt am"
#. 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 ""
+msgstr "Erzeugte Exporte löschen"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__display_name
msgid "Display Name"
-msgstr ""
+msgstr "Anzeigename"
#. module: base_export_async
#: code:addons/base_export_async/models/delay_export.py:110
#, python-format
msgid "Export {} {}"
-msgstr ""
+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 ""
+msgstr "Externe ID"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__id
msgid "ID"
-msgstr ""
+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 ""
+msgstr "Zuletzt geändert am"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_uid
msgid "Last Updated by"
-msgstr ""
+msgstr "Zuletzt aktualisiert von"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_date
msgid "Last Updated on"
-msgstr ""
+msgstr "Zuletzt aktualisiert am"
#. 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 ""
+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 ""
+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"
-msgstr ""
+msgstr "Benutzer"
#. module: base_export_async
#: code:addons/base_export_async/models/delay_export.py:29
#, python-format
msgid "You must set an email address to your user."
msgstr ""
+"Der aktuelle Benutzer hat keine Email-Adresse. Es muss eine gesetzt werden."
#. module: base_export_async
#. openerp-web
@@ -131,3 +143,4 @@ msgstr ""
#, 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."
From 8fe630c4316dac02d093da4bedc30e47a44dd6cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com>
Date: Thu, 25 Jul 2019 15:34:58 +0000
Subject: [PATCH 19/60] Added translation using Weblate (Chinese (Simplified))
---
base_export_async/i18n/zh_Hans.po | 133 ++++++++++++++++++++++++++++++
1 file changed, 133 insertions(+)
create mode 100644 base_export_async/i18n/zh_Hans.po
diff --git a/base_export_async/i18n/zh_Hans.po b/base_export_async/i18n/zh_Hans.po
new file mode 100644
index 0000000000..74ccdc368f
--- /dev/null
+++ b/base_export_async/i18n/zh_Hans.po
@@ -0,0 +1,133 @@
+# 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: zh_Hans\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: base_export_async
+#: code:addons/base_export_async/models/delay_export.py:112
+#, 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 "Allow to delay the 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:110
+#, 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
+#: 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"
+msgstr ""
+
+#. module: base_export_async
+#: code:addons/base_export_async/models/delay_export.py:29
+#, 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
+#, python-format
+msgid "You will receive the export file by email as soon as it is finished."
+msgstr ""
From 4f664905c736f87608bede44558d346cdc5bf5e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com>
Date: Thu, 25 Jul 2019 15:37:12 +0000
Subject: [PATCH 20/60] Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (19 of 19 strings)
Translation: queue-12.0/queue-12.0-base_export_async
Translate-URL: https://translation.odoo-community.org/projects/queue-12-0/queue-12-0-base_export_async/zh_Hans/
---
base_export_async/i18n/zh_Hans.po | 48 +++++++++++++++++++------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/base_export_async/i18n/zh_Hans.po b/base_export_async/i18n/zh_Hans.po
index 74ccdc368f..8d8974305c 100644
--- a/base_export_async/i18n/zh_Hans.po
+++ b/base_export_async/i18n/zh_Hans.po
@@ -6,13 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2019-07-25 17:43+0000\n"
+"Last-Translator: 黎伟杰 <674416404@qq.com>\n"
"Language-Team: none\n"
"Language: zh_Hans\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"
+"X-Generator: Weblate 3.7.1\n"
#. module: base_export_async
#: code:addons/base_export_async/models/delay_export.py:112
@@ -26,108 +28,116 @@ msgid "\n"
" \n"
" "
msgstr ""
+"\n"
+" 你的导出可以用 这里 .
\n"
+" 它将自动删除 {}。
\n"
+"
\n"
+" \n"
+" 这是一条自动消息,请不要回复。\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 ""
+msgstr "(您将通过电子邮件收到导出)"
#. module: base_export_async
#: model:ir.model,name:base_export_async.model_delay_export
msgid "Allow to delay the export"
-msgstr ""
+msgstr "允许延迟导出"
#. module: base_export_async
#. openerp-web
#: code:addons/base_export_async/static/src/xml/base.xml:9
#, python-format
msgid "Asynchronous export"
-msgstr ""
+msgstr "异步导出"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_uid
msgid "Created by"
-msgstr ""
+msgstr "创建者"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__create_date
msgid "Created on"
-msgstr ""
+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 ""
+msgstr "删除生成的导出"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__display_name
msgid "Display Name"
-msgstr ""
+msgstr "显示名称"
#. module: base_export_async
#: code:addons/base_export_async/models/delay_export.py:110
#, python-format
msgid "Export {} {}"
-msgstr ""
+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 ""
+msgstr "外部ID"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__id
msgid "ID"
-msgstr ""
+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 ""
+msgstr "最后修改时间"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_uid
msgid "Last Updated by"
-msgstr ""
+msgstr "最后更新者"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__write_date
msgid "Last Updated on"
-msgstr ""
+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 ""
+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 ""
+msgstr "用户没有电子邮件地址。"
#. module: base_export_async
#: model:ir.model.fields,field_description:base_export_async.field_delay_export__user_id
msgid "User"
-msgstr ""
+msgstr "用户"
#. module: base_export_async
#: code:addons/base_export_async/models/delay_export.py:29
#, python-format
msgid "You must set an email address to your user."
-msgstr ""
+msgstr "您必须为您的用户设置电子邮件地址。"
#. module: base_export_async
#. openerp-web
#: code:addons/base_export_async/static/src/js/data_export.js:91
#, python-format
msgid "You will receive the export file by email as soon as it is finished."
-msgstr ""
+msgstr "完成后,您将通过电子邮件收到导出文件。"
From 17882817206f9c752c2c584345e790c059175c05 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Mon, 29 Jul 2019 03:31:44 +0000
Subject: [PATCH 21/60] [UPD] README.rst
---
base_export_async/static/description/index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/base_export_async/static/description/index.html b/base_export_async/static/description/index.html
index 6a727127d5..7620c7e958 100644
--- a/base_export_async/static/description/index.html
+++ b/base_export_async/static/description/index.html
@@ -3,7 +3,7 @@
-
+
Base Export Async