Skip to content

Commit c60d4fb

Browse files
BT-jcamachosimahawk
authored andcommitted
[MIG] base_import_async: Migration to 14.0
1 parent ce1d0dd commit c60d4fb

File tree

10 files changed

+40
-27
lines changed

10 files changed

+40
-27
lines changed

.pre-commit-config.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ exclude: |
22
(?x)
33
# NOT INSTALLABLE ADDONS
44
^base_export_async/|
5-
^base_import_async/|
65
^queue_job_subscribe/|
7-
^test_base_import_async/|
86
# END NOT INSTALLABLE ADDONS
97
# Files and folders generated by bots, to avoid loops
108
^setup/|/static/description/index\.html$|

base_import_async/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
{
66
"name": "Asynchronous Import",
77
"summary": "Import CSV files in the background",
8-
"version": "13.0.2.0.0",
8+
"version": "14.0.1.0.0",
99
"author": "Akretion, ACSONE SA/NV, Odoo Community Association (OCA)",
1010
"license": "AGPL-3",
1111
"website": "https://github.com/OCA/queue",
1212
"category": "Generic Modules",
1313
"depends": ["base_import", "queue_job"],
1414
"data": ["data/queue_job_function_data.xml", "views/base_import_async.xml"],
1515
"qweb": ["static/src/xml/import.xml"],
16-
"installable": False,
16+
"installable": True,
1717
"development_status": "Production/Stable",
1818
}

base_import_async/models/base_import_import.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ def _read_csv_attachment(self, attachment, options):
111111

112112
@staticmethod
113113
def _extract_chunks(model_obj, fields, data, chunk_size):
114-
""" Split the data on record boundaries,
115-
in chunks of minimum chunk_size """
114+
"""Split the data on record boundaries, in chunks of minimum chunk_size"""
116115
fields = list(map(fix_import_export_id_paths, fields))
117116
row_from = 0
118117
for rows in model_obj._extract_records(fields, data):

base_import_async/static/src/js/import.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
odoo.define("base_import_async.import", function(require) {
1+
odoo.define("base_import_async.import", function (require) {
22
"use strict";
33

44
var core = require("web.core");
55
var _t = core._t;
66
var DataImport = require("base_import.import").DataImport;
77

88
DataImport.include({
9-
import_options: function() {
9+
import_options: function () {
1010
var options = this._super.apply(this, arguments);
1111
options.use_queue = this.$("input.oe_import_queue").prop("checked");
1212
return options;
1313
},
1414

15-
onimported: function() {
15+
onimported: function () {
1616
if (this.$("input.oe_import_queue").prop("checked")) {
17-
this.do_notify(
18-
_t("Your request is being processed"),
19-
_t("You can check the status of this job in menu 'Queue / Jobs'.")
20-
);
17+
this.displayNotification({
18+
type: "warning",
19+
title: _t("Your request is being processed"),
20+
message: _t(
21+
"You can check the status of this job in menu 'Queue / Jobs'."
22+
),
23+
});
2124
this.exit();
2225
} else {
2326
this._super.apply(this, arguments);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../base_import_async/

setup/base_import_async/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../test_base_import_async/

setup/test_base_import_async/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

test_base_import_async/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{
66
"name": "Test suite for base_import_async",
7-
"version": "13.0.1.0.0",
7+
"version": "14.0.1.0.0",
88
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
99
"license": "AGPL-3",
1010
"website": "https://github.com/OCA/queue",
@@ -15,6 +15,6 @@
1515
""",
1616
"depends": ["base_import_async", "account"],
1717
"data": [],
18-
"installable": False,
18+
"installable": True,
1919
"development_status": "Production/Stable",
2020
}

test_base_import_async/tests/test_base_import_async.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_async_import(self):
105105
self.assertEqual(len(split_job), 1)
106106
# job names are important
107107
self.assertEqual(
108-
split_job.name, "Import Journal Entries from file account.move.csv"
108+
split_job.name, "Import Journal Entry from file account.move.csv"
109109
)
110110
# perform job
111111
Job.load(self.env, split_job.uuid).perform()
@@ -114,7 +114,7 @@ def test_async_import(self):
114114
self.assertEqual(len(load_job), 1)
115115
self.assertEqual(
116116
load_job.name,
117-
"Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 10",
117+
"Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 10",
118118
)
119119
# perform job
120120
Job.load(self.env, load_job.uuid).perform()
@@ -134,11 +134,11 @@ def test_async_import_small_misaligned_chunks(self):
134134
self.assertEqual(len(load_jobs), 2)
135135
self.assertEqual(
136136
load_jobs[0].name,
137-
"Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 7",
137+
"Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 7",
138138
)
139139
self.assertEqual(
140140
load_jobs[1].name,
141-
"Import Journal Entries from file account.move.csv - " "#1 - lines 8 to 10",
141+
"Import Journal Entry from file account.move.csv - " "#1 - lines 8 to 10",
142142
)
143143
# perform job
144144
Job.load(self.env, load_jobs[0].uuid).perform()
@@ -159,15 +159,15 @@ def test_async_import_smaller_misaligned_chunks(self):
159159
self.assertEqual(len(load_jobs), 3)
160160
self.assertEqual(
161161
load_jobs[0].name,
162-
"Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 4",
162+
"Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 4",
163163
)
164164
self.assertEqual(
165165
load_jobs[1].name,
166-
"Import Journal Entries from file account.move.csv - " "#1 - lines 5 to 7",
166+
"Import Journal Entry from file account.move.csv - " "#1 - lines 5 to 7",
167167
)
168168
self.assertEqual(
169169
load_jobs[2].name,
170-
"Import Journal Entries from file account.move.csv - " "#2 - lines 8 to 10",
170+
"Import Journal Entry from file account.move.csv - " "#2 - lines 8 to 10",
171171
)
172172
# perform job
173173
Job.load(self.env, load_jobs[0].uuid).perform()
@@ -176,8 +176,7 @@ def test_async_import_smaller_misaligned_chunks(self):
176176
self._check_import_result()
177177

178178
def test_async_import_smaller_aligned_chunks(self):
179-
""" Chunks aligned on record boundaries.
180-
Last chunk ends exactly at file end. """
179+
"""Chunks aligned on record boundaries. Last chunk ends exactly at file end."""
181180
res = self._do_import("account.move.csv", use_queue=True, chunk_size=3)
182181
self.assertFalse(res, repr(res))
183182
# but we must have one job to split the file
@@ -190,15 +189,15 @@ def test_async_import_smaller_aligned_chunks(self):
190189
self.assertEqual(len(load_jobs), 3)
191190
self.assertEqual(
192191
load_jobs[0].name,
193-
"Import Journal Entries from file account.move.csv - " "#0 - lines 2 to 4",
192+
"Import Journal Entry from file account.move.csv - " "#0 - lines 2 to 4",
194193
)
195194
self.assertEqual(
196195
load_jobs[1].name,
197-
"Import Journal Entries from file account.move.csv - " "#1 - lines 5 to 7",
196+
"Import Journal Entry from file account.move.csv - " "#1 - lines 5 to 7",
198197
)
199198
self.assertEqual(
200199
load_jobs[2].name,
201-
"Import Journal Entries from file account.move.csv - " "#2 - lines 8 to 10",
200+
"Import Journal Entry from file account.move.csv - " "#2 - lines 8 to 10",
202201
)
203202
# perform job
204203
Job.load(self.env, load_jobs[0].uuid).perform()

0 commit comments

Comments
 (0)