[FIX] connector_opencart: bound template using archived variant

This commit is contained in:
Jared Kipe
2021-09-29 14:04:35 -07:00
parent 348af86ab2
commit 9572d634cf
2 changed files with 6 additions and 5 deletions

View File

@@ -18,6 +18,8 @@ class OpencartProductTemplate(models.Model):
string='Opencart Product Attribute Values')
def opencart_sale_get_combination(self, options, reentry=False):
if not options:
return self.odoo_id.product_variant_id
selected_attribute_values = self.env['product.template.attribute.value']
for option in options:
product_option_value_id = str(option['product_option_value_id'])

View File

@@ -443,9 +443,8 @@ class SaleOrderLineImportMapper(Component):
product_id = record['product_id']
binder = self.binder_for('opencart.product.template')
# do not unwrap, because it would be a product.template, but I need a specific variant
opencart_product_template = binder.to_internal(product_id, unwrap=False)
if record.get('option'):
product = opencart_product_template.opencart_sale_get_combination(record.get('option'))
else:
product = opencart_product_template.odoo_id.product_variant_id
# connector bindings are found with `active_test=False` but that also means computed fields
# like `product.template.product_variant_id` could find different products because of archived variants
opencart_product_template = binder.to_internal(product_id, unwrap=False).with_context(active_test=True)
product = opencart_product_template.opencart_sale_get_combination(record.get('option'))
return {'product_id': product.id, 'product_uom': product.uom_id.id}