Skip to content

Commit

Permalink
[MIG] base_import_async: Migration to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BT-jcamacho authored and simahawk committed Aug 10, 2021
1 parent ce1d0dd commit c60d4fb
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 27 deletions.
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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$|
Expand Down
4 changes: 2 additions & 2 deletions base_import_async/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
{
"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",
"category": "Generic Modules",
"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",
}
3 changes: 1 addition & 2 deletions base_import_async/models/base_import_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 10 additions & 7 deletions base_import_async/static/src/js/import.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
odoo.define("base_import_async.import", function(require) {
odoo.define("base_import_async.import", function (require) {
"use strict";

var core = require("web.core");
var _t = core._t;
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);
Expand Down
1 change: 1 addition & 0 deletions setup/base_import_async/odoo/addons/base_import_async
6 changes: 6 additions & 0 deletions setup/base_import_async/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
6 changes: 6 additions & 0 deletions setup/test_base_import_async/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
4 changes: 2 additions & 2 deletions test_base_import_async/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -15,6 +15,6 @@
""",
"depends": ["base_import_async", "account"],
"data": [],
"installable": False,
"installable": True,
"development_status": "Production/Stable",
}
23 changes: 11 additions & 12 deletions test_base_import_async/tests/test_base_import_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit c60d4fb

Please sign in to comment.