Skip to content

Commit

Permalink
[IMP] connector_ebisumart: change queue_job description
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Nov 22, 2024
1 parent 8c1db8f commit 8b46f3e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 5 additions & 1 deletion connector_ebisumart/components/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 15 additions & 3 deletions connector_ebisumart/models/ebisumart_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
10 changes: 8 additions & 2 deletions connector_ebisumart/models/ebisumart_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

0 comments on commit 8b46f3e

Please sign in to comment.