From c35a3ecd9810c8883202ab080fe8720fb843ec09 Mon Sep 17 00:00:00 2001 From: Reanova Migration Date: Thu, 28 May 2026 16:16:19 +0200 Subject: [PATCH] [MIG] base_import_async: Migration to 19.0 - bump version 18.0.1.0.0 -> 19.0.1.0.0 - installable False -> True - remove @api.returns("ir.attachment") decorator on _create_csv_attachment (decorator no longer supported in V19; the method already returns an ir.attachment recordset, so the decorator was redundant) - replace _() with self.env._() (W8161 prefer-env-translation) - use kwarg form of self.env._() instead of % formatting (W8301 translation-not-lazy); rename %(from)s/%(to)s to %(row_from)s/%(row_to)s to use as kwargs (from is a Python reserved word) - remove unused imports (_, api) - mark BaseImportImport with # pylint: disable=no-wizard-in-models (TransientModel extends core base_import.import which is itself in models/, following the upstream convention) - remove module from .pre-commit-config.yaml NOT INSTALLABLE list - add odoo-addon-base_import_async==19.0.* to setup/_metapackage dependencies Tested on a V19 install with a 35k-row partner CSV: import is correctly queued as a queue.job and processed in background. The ir.attachment returned by _create_csv_attachment is properly linked to the queue job (res_model="queue.job"). Note: queue_job_cron was dropped from this PR because its test_queue_job_cron_callback test fails on V19 due to an internal cr.commit() in ir.cron._callback (V19 forbids commit/rollback inside TransactionCase tests). That migration needs a separate PR with a test refactor (savepoint-based or testing-bus-mock based). --- .pre-commit-config.yaml | 1 - base_import_async/__manifest__.py | 4 +-- .../models/base_import_import.py | 30 +++++++++---------- base_import_async/models/queue_job.py | 4 +-- setup/_metapackage/pyproject.toml | 1 + 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4cefd00cac..af6b972525 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,6 @@ exclude: | (?x) # NOT INSTALLABLE ADDONS - ^base_import_async/| ^queue_job_batch/| ^queue_job_cron/| ^queue_job_cron_jobrunner/| diff --git a/base_import_async/__manifest__.py b/base_import_async/__manifest__.py index 5432d7c5ca..58dd6eb8b0 100644 --- a/base_import_async/__manifest__.py +++ b/base_import_async/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Asynchronous Import", "summary": "Import CSV files in the background", - "version": "18.0.1.0.0", + "version": "19.0.1.0.0", "author": "Akretion, ACSONE SA/NV, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/queue", @@ -20,6 +20,6 @@ "base_import_async/static/src/xml/import_data_sidepanel.xml", ], }, - "installable": False, + "installable": True, "development_status": "Production/Stable", } diff --git a/base_import_async/models/base_import_import.py b/base_import_async/models/base_import_import.py index 856828a593..c655572413 100644 --- a/base_import_async/models/base_import_import.py +++ b/base_import_async/models/base_import_import.py @@ -9,7 +9,7 @@ from io import BytesIO, StringIO, TextIOWrapper from os.path import splitext -from odoo import _, api, models +from odoo import models from odoo.models import fix_import_export_id_paths from odoo.addons.base_import.models.base_import import ImportValidationError @@ -30,6 +30,7 @@ DEFAULT_CHUNK_SIZE = 100 +# pylint: disable=no-wizard-in-models class BaseImportImport(models.TransientModel): _inherit = "base_import.import" @@ -55,10 +56,11 @@ def execute_import(self, fields, columns, options, dryrun=False): translated_model_name = search_result[0][1] else: translated_model_name = self._description - description = _("Import %(model)s from file %(from_file)s") % { - "model": translated_model_name, - "from_file": self.file_name, - } + description = self.env._( + "Import %(model)s from file %(from_file)s", + model=translated_model_name, + from_file=self.file_name, + ) attachment = self._create_csv_attachment( import_fields, data, options, self.file_name ) @@ -78,7 +80,6 @@ def _link_attachment_to_job(self, delayed_job, attachment): ) attachment.write({"res_model": "queue.job", "res_id": queue_job.id}) - @api.returns("ir.attachment") def _create_csv_attachment(self, fields, data, options, file_name): # write csv f = StringIO() @@ -155,16 +156,15 @@ def _split_file( model_obj, fields, data, chunk_size ): chunk = str(priority - INIT_PRIORITY).zfill(padding) - description = _( + description = self.env._( "Import %(model)s from file %(file_name)s - " - "#%(chunk)s - lines %(from)s to %(to)s" - ) % { - "model": translated_model_name, - "file_name": file_name, - "chunk": chunk, - "from": row_from + 1 + header_offset, - "to": row_to + 1 + header_offset, - } + "#%(chunk)s - lines %(row_from)s to %(row_to)s", + model=translated_model_name, + file_name=file_name, + chunk=chunk, + row_from=row_from + 1 + header_offset, + row_to=row_to + 1 + header_offset, + ) # create a CSV attachment and enqueue the job root, ext = splitext(file_name) attachment = self._create_csv_attachment( diff --git a/base_import_async/models/queue_job.py b/base_import_async/models/queue_job.py index b7313505f3..f3034e9d54 100644 --- a/base_import_async/models/queue_job.py +++ b/base_import_async/models/queue_job.py @@ -1,7 +1,7 @@ # Copyright 2017 ACSONE SA/NV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, models +from odoo import models class QueueJob(models.Model): @@ -11,7 +11,7 @@ class QueueJob(models.Model): def _related_action_attachment(self): return { - "name": _("Attachment"), + "name": self.env._("Attachment"), "type": "ir.actions.act_window", "res_model": "ir.attachment", "view_mode": "form", diff --git a/setup/_metapackage/pyproject.toml b/setup/_metapackage/pyproject.toml index d816e8ea04..f008a75218 100644 --- a/setup/_metapackage/pyproject.toml +++ b/setup/_metapackage/pyproject.toml @@ -2,6 +2,7 @@ name = "odoo-addons-oca-queue" version = "19.0.20260104.0" dependencies = [ + "odoo-addon-base_import_async==19.0.*", "odoo-addon-queue_job==19.0.*", "odoo-addon-test_queue_job==19.0.*", ]