From a1d5364cdff6626a568615c1ff4524cd53223b3a Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Wed, 15 Jun 2022 21:33:51 +0000 Subject: [PATCH] [IMP] connector_opencart: add product name/skus to checkpoint activity --- connector_opencart/models/opencart/backend.py | 5 ++++- connector_opencart/models/product/importer.py | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/connector_opencart/models/opencart/backend.py b/connector_opencart/models/opencart/backend.py index a44d231b..c347c254 100644 --- a/connector_opencart/models/opencart/backend.py +++ b/connector_opencart/models/opencart/backend.py @@ -102,18 +102,21 @@ class OpencartBackend(models.Model): with _super.work_on(model_name, opencart_api=opencart_api, **kwargs) as work: yield work - def add_checkpoint(self, record): + def add_checkpoint(self, record, summary=''): self.ensure_one() record.ensure_one() user = self.env.user + summary = summary or self.env.context.get('checkpoint_summary', '') if 'user_id' in record and record.user_id: user = record.user_id if 'odoo_id' in record: return record.odoo_id.activity_schedule( act_type_xmlid='connector_opencart.checkpoint', + summary=summary, user_id=user.id) return record.activity_schedule( act_type_xmlid='connector_opencart.checkpoint', + summary=summary, user_id=user.id) def find_checkpoint(self, record): diff --git a/connector_opencart/models/product/importer.py b/connector_opencart/models/product/importer.py index 6618cf11..b5043567 100644 --- a/connector_opencart/models/product/importer.py +++ b/connector_opencart/models/product/importer.py @@ -55,6 +55,16 @@ class ProductImportMapper(Component): if name: template = product_template.search([('name', '=', unescape(name))], limit=1) return {'odoo_id': template.id} + + @mapping + def checkpoint_summary(self, record): + pieces = [ + str(record.get('model') or '').strip(), + str(record.get('sku') or '').strip(), + str(record.get('product_description', [{}])[0].get('name') or '').strip(), + ] + pieces = [t for t in pieces if t] + return {'checkpoint_summary': ' : '.join(pieces)} class ProductImporter(Component): @@ -63,8 +73,11 @@ class ProductImporter(Component): _apply_on = ['opencart.product.template'] def _create(self, data): + checkpoint_summary = data.get('checkpoint_summary', '') + if 'checkpoint_summary' in data: + del data['checkpoint_summary'] binding = super(ProductImporter, self)._create(data) - self.backend_record.add_checkpoint(binding) + self.backend_record.add_checkpoint(binding, summary=checkpoint_summary) return binding def _after_import(self, binding):