From 8b46f3e87507bd0baacb97f0f818ee03f49b2420 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Fri, 22 Nov 2024 18:11:19 +0800 Subject: [PATCH] [IMP] connector_ebisumart: change queue_job description --- connector_ebisumart/components/importer.py | 6 +++++- .../models/ebisumart_backend.py | 18 +++++++++++++++--- .../models/ebisumart_binding.py | 10 ++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/connector_ebisumart/components/importer.py b/connector_ebisumart/components/importer.py index 99d0f49..3264f3f 100644 --- a/connector_ebisumart/components/importer.py +++ b/connector_ebisumart/components/importer.py @@ -319,5 +319,9 @@ class DelayedBatchImporter(AbstractComponent): def _import_record(self, external_id, job_options=None, **kwargs): """ Delay the import of the records""" - delayable = self.model.with_delay(**job_options or {}) + job_options = job_options or {} + job_options['description'] = ( + f'JOB: Import an Ebisumart record ({self.model._description})' + ) + delayable = self.model.with_delay(**job_options) delayable.import_record(self.backend_record, external_id, **kwargs) diff --git a/connector_ebisumart/models/ebisumart_backend.py b/connector_ebisumart/models/ebisumart_backend.py index bf487ae..3748aa7 100644 --- a/connector_ebisumart/models/ebisumart_backend.py +++ b/connector_ebisumart/models/ebisumart_backend.py @@ -154,24 +154,36 @@ def add_checkpoint(self, record): @api.multi def _import_orders(self, model): + description = ( + f'JOB: Prepare the import of records modified in Ebisumart ' + f'({self.env[model]._description})' + ) for backend in self: - self.env[model].with_delay().import_batch( + self.env[model].with_delay(description=description).import_batch( backend, filters=None ) @api.multi def _import_partners(self, model): + description = ( + f'JOB: Prepare the import of records modified in Ebisumart ' + f'({self.env[model]._description})' + ) for backend in self: - self.env[model].with_delay().import_batch( + self.env[model].with_delay(description=description).import_batch( backend, filters=None ) @api.multi def _import_products(self, model): + description = ( + f'JOB: Prepare the import of records modified in Ebisumart ' + f'({self.env[model]._description})' + ) for backend in self: - self.env[model].with_delay().import_batch( + self.env[model].with_delay(description=description).import_batch( backend, filters=None ) diff --git a/connector_ebisumart/models/ebisumart_binding.py b/connector_ebisumart/models/ebisumart_binding.py index 9273c47..bae0fd3 100644 --- a/connector_ebisumart/models/ebisumart_binding.py +++ b/connector_ebisumart/models/ebisumart_binding.py @@ -27,7 +27,11 @@ class EbisumartBinding(models.AbstractModel): @api.model def import_batch(self, backend, filters=None): - """ Prepare the import of records modified on Ebisumart """ + """ Prepare the import of records modified in Ebisumart. + This will create a queue job to fetch the list of modified records + from Ebisumart, and subsequently prepare individual queue jobs for + each record to be imported. + """ if filters is None: filters = {} with backend.work_on(self._name) as work: @@ -36,7 +40,9 @@ def import_batch(self, backend, filters=None): @api.model def import_record(self, backend, external_id, force=False): - """ Import a Ebisumart record """ + """Import an Ebisumart record. + This will import the Ebisumart record into Odoo when its queue job is run. + """ with backend.work_on(self._name) as work: importer = work.component(usage='record.importer') return importer.run(external_id, force=force)