Skip to content

Commit

Permalink
[MIG] base_import_async: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodran14 committed Sep 3, 2024
1 parent bf4ffa1 commit fb27984
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 42 deletions.
6 changes: 3 additions & 3 deletions base_import_async/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Asynchronous Import",
"summary": "Import CSV files in the background",
"version": "16.0.1.1.2",
"version": "17.0.1.0.0",
"author": "Akretion, ACSONE SA/NV, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/queue",
Expand All @@ -16,8 +16,8 @@
],
"assets": {
"web.assets_backend": [
"base_import_async/static/src/js/import.js",
"base_import_async/static/src/xml/import.xml",
"base_import_async/static/src/js/import_model.esm.js",
"base_import_async/static/src/xml/import_data_sidepanel.xml",
],
},
"installable": True,
Expand Down
3 changes: 2 additions & 1 deletion base_import_async/models/base_import_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def _create_csv_attachment(self, fields, data, options, file_name):
)
return attachment

Check warning on line 105 in base_import_async/models/base_import_import.py

View check run for this annotation

Codecov / codecov/patch

base_import_async/models/base_import_import.py#L105

Added line #L105 was not covered by tests

def _read_csv_attachment(self, attachment, options):
@staticmethod
def _read_csv_attachment(attachment, options):
decoded_datas = base64.decodebytes(attachment.datas)
encoding = options.get(OPT_ENCODING) or "utf-8"
f = TextIOWrapper(BytesIO(decoded_datas), encoding=encoding)
Expand Down
6 changes: 2 additions & 4 deletions base_import_async/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ class QueueJob(models.Model):
_inherit = "queue.job"

def _related_action_attachment(self):
res_id = self.kwargs.get("att_id")
action = {
return {

Check warning on line 13 in base_import_async/models/queue_job.py

View check run for this annotation

Codecov / codecov/patch

base_import_async/models/queue_job.py#L13

Added line #L13 was not covered by tests
"name": _("Attachment"),
"type": "ir.actions.act_window",
"res_model": "ir.attachment",
"view_mode": "form",
"res_id": res_id,
"res_id": self.kwargs.get("att_id"),
}
return action
30 changes: 0 additions & 30 deletions base_import_async/static/src/js/import.js

This file was deleted.

26 changes: 26 additions & 0 deletions base_import_async/static/src/js/import_model.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @odoo-module **/

import {BaseImportModel} from "@base_import/import_model";
import {_t} from "@web/core/l10n/translation";
import {patch} from "@web/core/utils/patch";

patch(BaseImportModel.prototype, {
get importOptions() {
const options = super.importOptions;
const checkbox = document.querySelector("input.oe_import_queue");
options.use_queue = checkbox ? checkbox.checked : false;
return options;
},

async executeImport(isTest, totalSteps, importProgress) {
const def = super.executeImport(isTest, totalSteps, importProgress);
const checkbox = document.querySelector("input.oe_import_queue");
if (checkbox && checkbox.checked && !isTest) {
this._addMessage("warning", [
_t("Your request is being processed"),
_t("You can check the status of this job in menu 'Queue / Jobs'."),
]);
}
return def;
},
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<t t-extend="ImportView.side_panel">
<t t-jquery="#oe_import_has_header" t-operation="before">
<templates xml:space="preserve">
<t
t-name="base_import_async.ImportDataSidepanel"
t-inherit="base_import.ImportDataSidepanel"
t-inherit-mode="extension"
>
<xpath expr="//CheckBox" position="before">
<div
title="When checked, the import will be executed as a background job,
after splitting your file in small chunks that will be processed independently.
Expand All @@ -14,6 +18,6 @@ Use this to import very large files."
/>
<label for="oe_import_queue">Import in the background</label>
</div>
</t>
</xpath>
</t>
</templates>

0 comments on commit fb27984

Please sign in to comment.