Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion base_import_async/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
{
'name': 'Asynchronous Import',
'summary': 'Import CSV files in the background',
'version': '11.0.1.0.0',
'version': '11.0.2.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',
'queue_job_batch',
],
'data': [
'views/base_import_async.xml',
Expand Down
7 changes: 6 additions & 1 deletion base_import_async/models/base_import_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import csv
import base64
from datetime import datetime
from os.path import splitext
from io import StringIO, TextIOWrapper, BytesIO

Expand Down Expand Up @@ -147,6 +148,8 @@ def _split_file(self, model_name, translated_model_name,
else:
header_offset = 0
chunk_size = options.get(OPT_CHUNK_SIZE) or DEFAULT_CHUNK_SIZE
batch_name = '%s (%s)' % (file_name, datetime.today())
batch = self.env['queue.job.batch'].get_new_batch(batch_name)
for row_from, row_to in self._extract_chunks(
model_obj, fields, data, chunk_size):
chunk = str(priority - INIT_PRIORITY).zfill(padding)
Expand All @@ -161,13 +164,15 @@ def _split_file(self, model_name, translated_model_name,
attachment = self._create_csv_attachment(
fields, data[row_from:row_to + 1], options,
file_name=root + '-' + chunk + ext)
delayed_job = self.with_delay(
delayed_job = self.with_context(
job_batch=batch).with_delay(
description=description, priority=priority)._import_one_chunk(
model_name=model_name,
attachment=attachment,
options=options)
self._link_attachment_to_job(delayed_job, attachment)
priority += 1
batch.enqueue()

@api.model
@job
Expand Down
6 changes: 6 additions & 0 deletions base_import_async/readme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
11.0.2.0.0 (2019-07-08)
~~~~~~~~~~~~~~~~~~~~~~~

* Add dependency with module 'queue_job_batch', allowing the user to display
the progress of the import from the top bar.

11.0.1.0.0 (2018-06-26)
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down