diff --git a/base_import_async/__manifest__.py b/base_import_async/__manifest__.py index 735f5b09a..77f0750a7 100644 --- a/base_import_async/__manifest__.py +++ b/base_import_async/__manifest__.py @@ -7,7 +7,7 @@ { 'name': 'Asynchronous Import', 'summary': 'Import CSV files in the background', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'Akretion, ACSONE SA/NV, Odoo Community Association (OCA)', 'license': 'AGPL-3', 'website': 'https://github.com/OCA/queue', @@ -22,5 +22,6 @@ 'qweb': [ 'static/src/xml/import.xml', ], - 'installable': False, + 'installable': True, + 'development_status': 'Stable', } diff --git a/base_import_async/models/base_import_import.py b/base_import_async/models/base_import_import.py index 850ea6fba..080bd6981 100644 --- a/base_import_async/models/base_import_import.py +++ b/base_import_async/models/base_import_import.py @@ -34,11 +34,11 @@ class BaseImportImport(models.TransientModel): _inherit = 'base_import.import' @api.multi - def do(self, fields, options, dryrun=False): + def do(self, fields, columns, options, dryrun=False): if dryrun or not options.get(OPT_USE_QUEUE): # normal import return super(BaseImportImport, self).do( - fields, options, dryrun=dryrun) + fields, columns, options, dryrun=dryrun) # asynchronous import try: @@ -89,9 +89,9 @@ def _create_csv_attachment(self, fields, data, options, file_name): # write csv f = StringIO() writer = csv.writer(f, - delimiter=str(options.get(OPT_SEPARATOR)), + delimiter=str(options.get(OPT_SEPARATOR)) or ',', quotechar=str(options.get(OPT_QUOTING))) - encoding = options.get(OPT_ENCODING, 'utf-8') + encoding = options.get(OPT_ENCODING) or 'utf-8' writer.writerow(fields) for row in data: writer.writerow(row) @@ -107,10 +107,10 @@ def _create_csv_attachment(self, fields, data, options, file_name): @api.model def _read_csv_attachment(self, attachment, options): decoded_datas = base64.decodebytes(attachment.datas) - encoding = options.get(OPT_ENCODING, 'utf-8') + encoding = options.get(OPT_ENCODING) or 'utf-8' f = TextIOWrapper(BytesIO(decoded_datas), encoding=encoding) reader = csv.reader(f, - delimiter=str(options.get(OPT_SEPARATOR)), + delimiter=str(options.get(OPT_SEPARATOR)) or ',', quotechar=str(options.get(OPT_QUOTING))) fields = next(reader) diff --git a/base_import_async/readme/HISTORY.rst b/base_import_async/readme/HISTORY.rst index 630d9ebaa..6ef5491de 100644 --- a/base_import_async/readme/HISTORY.rst +++ b/base_import_async/readme/HISTORY.rst @@ -1,4 +1,4 @@ -11.0.1.0.0 (2018-06-26) +12.0.1.0.0 (2018-10-20) ~~~~~~~~~~~~~~~~~~~~~~~ -* [BREAKING] In the `do` method the `use_connector` option has changed to `use_queue`. +* [MIGRATION] from 11.0 branched at rev. b0945be diff --git a/base_import_async/static/src/js/import.js b/base_import_async/static/src/js/import.js index 9cff3b58a..3fcab6fc9 100644 --- a/base_import_async/static/src/js/import.js +++ b/base_import_async/static/src/js/import.js @@ -19,8 +19,10 @@ odoo.define('base_import_async.import', function (require) { _t("Your request is being processed"), _t("You can check the status of this job in menu 'Queue / Jobs'.") ); + this.exit(); + } else { + this._super.apply(this, arguments); } - 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 000000000..0a110e42a --- /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 000000000..28c57bb64 --- /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 000000000..1da8a69c6 --- /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 000000000..28c57bb64 --- /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 74ea14f82..6440613e8 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': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'ACSONE SA/NV, Odoo Community Association (OCA)', 'license': 'AGPL-3', 'website': 'https://github.com/OCA/queue', @@ -20,5 +20,6 @@ 'data': [ 'tests/data.xml', ], - 'installable': False, + 'installable': True, + 'development_status': 'Stable', } diff --git a/test_base_import_async/readme/CONTRIBUTORS.rst b/test_base_import_async/readme/CONTRIBUTORS.rst index 4072a82e9..fcf4d3324 100644 --- a/test_base_import_async/readme/CONTRIBUTORS.rst +++ b/test_base_import_async/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Stéphane Bidoul (ACSONE) * Dennis Sluijk (Onestein) +* Guewen Baconnier (Camptocamp) diff --git a/test_base_import_async/tests/data.xml b/test_base_import_async/tests/data.xml index 254120052..d5bd35f92 100644 --- a/test_base_import_async/tests/data.xml +++ b/test_base_import_async/tests/data.xml @@ -1,6 +1,6 @@ - + ir.model.fields 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 5d80bbe82..7e2ae9446 100644 --- a/test_base_import_async/tests/test_base_import_async.py +++ b/test_base_import_async/tests/test_base_import_async.py @@ -29,6 +29,7 @@ class TestBaseImportAsync(common.TransactionCase): OPT_SEPARATOR: ',', OPT_QUOTING: '"', OPT_HAS_HEADER: True, + 'date_format': '%Y-%m-%d', } def setUp(self): @@ -51,7 +52,7 @@ def _do_import(self, file_name, use_queue, chunk_size=None): options = dict(self.OPTIONS) options[OPT_USE_QUEUE] = use_queue options[OPT_CHUNK_SIZE] = chunk_size - return importer.do(self.FIELDS, options) + return importer.do(self.FIELDS, self.FIELDS, options) def _check_import_result(self): move_count = self.move_obj.search_count( @@ -61,7 +62,7 @@ def _check_import_result(self): def test_normal_import(self): """ Test the standard import still works. """ res = self._do_import('account.move.csv', use_queue=False) - self.assertFalse(res, repr(res)) + self.assertFalse(res['messages'], repr(res)) self._check_import_result() def test_async_import(self): @@ -77,14 +78,14 @@ def test_async_import(self): self.assertEqual(len(split_job), 1) # job names are important self.assertEqual(split_job.name, - "Import Account Entry from file account.move.csv") + "Import Journal Entries from file account.move.csv") # perform job Job.load(self.env, split_job.uuid).perform() # check one job has been generated to load the file (one chunk) load_job = self.job_obj.search([('id', '!=', split_job.id)]) self.assertEqual(len(load_job), 1) self.assertEqual(load_job.name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 10") # perform job Job.load(self.env, load_job.uuid).perform() @@ -105,10 +106,10 @@ def test_async_import_small_misaligned_chunks(self): [('id', '!=', split_job.id)], order='name') self.assertEqual(len(load_jobs), 2) self.assertEqual(load_jobs[0].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 7") self.assertEqual(load_jobs[1].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#1 - lines 8 to 10") # perform job Job.load(self.env, load_jobs[0].uuid).perform() @@ -130,13 +131,13 @@ def test_async_import_smaller_misaligned_chunks(self): [('id', '!=', split_job.id)], order='name') self.assertEqual(len(load_jobs), 3) self.assertEqual(load_jobs[0].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 4") self.assertEqual(load_jobs[1].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#1 - lines 5 to 7") self.assertEqual(load_jobs[2].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#2 - lines 8 to 10") # perform job Job.load(self.env, load_jobs[0].uuid).perform() @@ -160,13 +161,13 @@ def test_async_import_smaller_aligned_chunks(self): [('id', '!=', split_job.id)], order='name') self.assertEqual(len(load_jobs), 3) self.assertEqual(load_jobs[0].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 4") self.assertEqual(load_jobs[1].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#1 - lines 5 to 7") self.assertEqual(load_jobs[2].name, - "Import Account Entry from file account.move.csv - " + "Import Journal Entries from file account.move.csv - " "#2 - lines 8 to 10") # perform job Job.load(self.env, load_jobs[0].uuid).perform()