diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a46829c94..1fc776e540 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,9 +2,7 @@ exclude: | (?x) # NOT INSTALLABLE ADDONS ^base_export_async/| - ^base_import_async/| ^queue_job_subscribe/| - ^test_base_import_async/| # END NOT INSTALLABLE ADDONS # Files and folders generated by bots, to avoid loops ^setup/|/static/description/index\.html$| diff --git a/base_import_async/__manifest__.py b/base_import_async/__manifest__.py index 35901ecc46..187f19df97 100644 --- a/base_import_async/__manifest__.py +++ b/base_import_async/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Asynchronous Import", "summary": "Import CSV files in the background", - "version": "13.0.2.0.0", + "version": "14.0.1.0.0", "author": "Akretion, ACSONE SA/NV, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/queue", @@ -13,6 +13,6 @@ "depends": ["base_import", "queue_job"], "data": ["data/queue_job_function_data.xml", "views/base_import_async.xml"], "qweb": ["static/src/xml/import.xml"], - "installable": False, + "installable": True, "development_status": "Production/Stable", } diff --git a/base_import_async/models/base_import_import.py b/base_import_async/models/base_import_import.py index 4db93532bf..de08c5efb1 100644 --- a/base_import_async/models/base_import_import.py +++ b/base_import_async/models/base_import_import.py @@ -111,8 +111,7 @@ def _read_csv_attachment(self, attachment, options): @staticmethod def _extract_chunks(model_obj, fields, data, chunk_size): - """ Split the data on record boundaries, - in chunks of minimum chunk_size """ + """Split the data on record boundaries, in chunks of minimum chunk_size""" fields = list(map(fix_import_export_id_paths, fields)) row_from = 0 for rows in model_obj._extract_records(fields, data): diff --git a/base_import_async/static/src/js/import.js b/base_import_async/static/src/js/import.js index d1fc43d273..e79173dd76 100644 --- a/base_import_async/static/src/js/import.js +++ b/base_import_async/static/src/js/import.js @@ -1,4 +1,4 @@ -odoo.define("base_import_async.import", function(require) { +odoo.define("base_import_async.import", function (require) { "use strict"; var core = require("web.core"); @@ -6,18 +6,21 @@ odoo.define("base_import_async.import", function(require) { var DataImport = require("base_import.import").DataImport; DataImport.include({ - import_options: function() { + import_options: function () { var options = this._super.apply(this, arguments); options.use_queue = this.$("input.oe_import_queue").prop("checked"); return options; }, - onimported: function() { + onimported: function () { if (this.$("input.oe_import_queue").prop("checked")) { - this.do_notify( - _t("Your request is being processed"), - _t("You can check the status of this job in menu 'Queue / Jobs'.") - ); + this.displayNotification({ + type: "warning", + title: _t("Your request is being processed"), + message: _t( + "You can check the status of this job in menu 'Queue / Jobs'." + ), + }); this.exit(); } else { this._super.apply(this, arguments); diff --git a/setup/base_import_async/odoo/addons/base_import_async b/setup/base_import_async/odoo/addons/base_import_async new file mode 120000 index 0000000000..9c5e2709fa --- /dev/null +++ b/setup/base_import_async/odoo/addons/base_import_async @@ -0,0 +1 @@ +../../../../base_import_async/ \ No newline at end of file diff --git a/setup/base_import_async/setup.py b/setup/base_import_async/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/base_import_async/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/test_base_import_async/odoo/addons/test_base_import_async b/setup/test_base_import_async/odoo/addons/test_base_import_async new file mode 120000 index 0000000000..5a932030c6 --- /dev/null +++ b/setup/test_base_import_async/odoo/addons/test_base_import_async @@ -0,0 +1 @@ +../../../../test_base_import_async/ \ No newline at end of file diff --git a/setup/test_base_import_async/setup.py b/setup/test_base_import_async/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/test_base_import_async/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test_base_import_async/__manifest__.py b/test_base_import_async/__manifest__.py index 5e0bfd6968..95428ec57f 100644 --- a/test_base_import_async/__manifest__.py +++ b/test_base_import_async/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Test suite for base_import_async", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/queue", @@ -15,6 +15,6 @@ """, "depends": ["base_import_async", "account"], "data": [], - "installable": False, + "installable": True, "development_status": "Production/Stable", } diff --git a/test_base_import_async/tests/test_base_import_async.py b/test_base_import_async/tests/test_base_import_async.py index f88924389f..59494fbc9b 100644 --- a/test_base_import_async/tests/test_base_import_async.py +++ b/test_base_import_async/tests/test_base_import_async.py @@ -105,7 +105,7 @@ def test_async_import(self): self.assertEqual(len(split_job), 1) # job names are important self.assertEqual( - split_job.name, "Import Journal Entries from file account.move.csv" + split_job.name, "Import Journal Entry from file account.move.csv" ) # perform job Job.load(self.env, split_job.uuid).perform() @@ -114,7 +114,7 @@ def test_async_import(self): self.assertEqual(len(load_job), 1) self.assertEqual( load_job.name, - "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 10", + "Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 10", ) # perform job Job.load(self.env, load_job.uuid).perform() @@ -134,11 +134,11 @@ def test_async_import_small_misaligned_chunks(self): self.assertEqual(len(load_jobs), 2) self.assertEqual( load_jobs[0].name, - "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 7", + "Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 7", ) self.assertEqual( load_jobs[1].name, - "Import Journal Entries from file account.move.csv - " "#1 - lines 8 to 10", + "Import Journal Entry from file account.move.csv - " "#1 - lines 8 to 10", ) # perform job Job.load(self.env, load_jobs[0].uuid).perform() @@ -159,15 +159,15 @@ def test_async_import_smaller_misaligned_chunks(self): self.assertEqual(len(load_jobs), 3) self.assertEqual( load_jobs[0].name, - "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 4", + "Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 4", ) self.assertEqual( load_jobs[1].name, - "Import Journal Entries from file account.move.csv - " "#1 - lines 5 to 7", + "Import Journal Entry from file account.move.csv - " "#1 - lines 5 to 7", ) self.assertEqual( load_jobs[2].name, - "Import Journal Entries from file account.move.csv - " "#2 - lines 8 to 10", + "Import Journal Entry from file account.move.csv - " "#2 - lines 8 to 10", ) # perform job Job.load(self.env, load_jobs[0].uuid).perform() @@ -176,8 +176,7 @@ def test_async_import_smaller_misaligned_chunks(self): self._check_import_result() def test_async_import_smaller_aligned_chunks(self): - """ Chunks aligned on record boundaries. - Last chunk ends exactly at file end. """ + """Chunks aligned on record boundaries. Last chunk ends exactly at file end.""" res = self._do_import("account.move.csv", use_queue=True, chunk_size=3) self.assertFalse(res, repr(res)) # but we must have one job to split the file @@ -190,15 +189,15 @@ def test_async_import_smaller_aligned_chunks(self): self.assertEqual(len(load_jobs), 3) self.assertEqual( load_jobs[0].name, - "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 4", + "Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 4", ) self.assertEqual( load_jobs[1].name, - "Import Journal Entries from file account.move.csv - " "#1 - lines 5 to 7", + "Import Journal Entry from file account.move.csv - " "#1 - lines 5 to 7", ) self.assertEqual( load_jobs[2].name, - "Import Journal Entries from file account.move.csv - " "#2 - lines 8 to 10", + "Import Journal Entry from file account.move.csv - " "#2 - lines 8 to 10", ) # perform job Job.load(self.env, load_jobs[0].uuid).perform()