[FIX] website_sale_comparison: use variant id and not product id

Before this commit, the compare button from the customized view "Alternative
Products" would create the URL by joining `alternative_product_ids` which are
ids from product.template.
But the route /shop/compare is supposed to receive variants (product.product)
IDs.
Thus, it would try to search given product.template IDs in product.product
records.
It would then show incorrect items or no items at all if the ID does not exist.

Now, we create the URL with the first variant (product.product) of the
product.template.
Obviously, the first product.product is arbitrary but we can't retrieve all the
variants ids, it would most of the time returns too many items.

opw-1840321
This commit is contained in:
Romain Derie
2018-05-04 12:58:20 +02:00
parent f49a6b6ebe
commit b5516d400e
@@ -57,7 +57,7 @@
<template id='recommended_product' inherit_id="website_sale.recommended_products" name="Alternative Products">
<xpath expr="//h3" position="replace">
<t t-set="ids" t-value="str(product.id) + ','+ ','.join([str(a) for a in product.alternative_product_ids.ids])"></t>
<t t-set="ids" t-value="str(product.product_variant_id.id) + ','+ ','.join([str(a) for a in product.alternative_product_ids.mapped('product_variant_id.id')])"/>
<div><span class='h3'>Suggested alternatives: </span><a class="btn btn-primary" t-attf-href="/shop/compare/?products=#{ids}"><i class="fa fa-exchange"></i> Compare</a></div>
</xpath>
</template>