Merge branch '15.0' into imp/15.0/connector_opencart__custom_attr_and_so_status

This commit is contained in:
Jared Kipe
2022-11-09 19:22:01 +00:00
2 changed files with 18 additions and 2 deletions

View File

@@ -102,18 +102,21 @@ class OpencartBackend(models.Model):
with _super.work_on(model_name, opencart_api=opencart_api, **kwargs) as work: with _super.work_on(model_name, opencart_api=opencart_api, **kwargs) as work:
yield work yield work
def add_checkpoint(self, record): def add_checkpoint(self, record, summary=''):
self.ensure_one() self.ensure_one()
record.ensure_one() record.ensure_one()
user = self.env.user user = self.env.user
summary = summary or self.env.context.get('checkpoint_summary', '')
if 'user_id' in record and record.user_id: if 'user_id' in record and record.user_id:
user = record.user_id user = record.user_id
if 'odoo_id' in record: if 'odoo_id' in record:
return record.odoo_id.activity_schedule( return record.odoo_id.activity_schedule(
act_type_xmlid='connector_opencart.checkpoint', act_type_xmlid='connector_opencart.checkpoint',
summary=summary,
user_id=user.id) user_id=user.id)
return record.activity_schedule( return record.activity_schedule(
act_type_xmlid='connector_opencart.checkpoint', act_type_xmlid='connector_opencart.checkpoint',
summary=summary,
user_id=user.id) user_id=user.id)
def find_checkpoint(self, record): def find_checkpoint(self, record):

View File

@@ -56,6 +56,16 @@ class ProductImportMapper(Component):
template = product_template.search([('name', '=', unescape(name))], limit=1) template = product_template.search([('name', '=', unescape(name))], limit=1)
return {'odoo_id': template.id} 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): class ProductImporter(Component):
_name = 'opencart.product.template.importer' _name = 'opencart.product.template.importer'
@@ -63,8 +73,11 @@ class ProductImporter(Component):
_apply_on = ['opencart.product.template'] _apply_on = ['opencart.product.template']
def _create(self, data): 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) binding = super(ProductImporter, self)._create(data)
self.backend_record.add_checkpoint(binding) self.backend_record.add_checkpoint(binding, summary=checkpoint_summary)
return binding return binding
def _after_import(self, binding): def _after_import(self, binding):