From 3cc4785ba6d27475323a606fef9466286024ad0e Mon Sep 17 00:00:00 2001
From: Christophe Matthieu <chm@odoo.com>
Date: Mon, 2 Jun 2014 12:11:54 +0200
Subject: [PATCH] [FIX] website_sale: display accessory field in form view and
 display the good accessory product inside ecommerce

---
 addons/website_sale/models/sale_order.py | 2 +-
 addons/website_sale/views/templates.xml  | 4 ++--
 addons/website_sale/views/views.xml      | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py
index 56162cb21395..d98550340186 100644
--- a/addons/website_sale/models/sale_order.py
+++ b/addons/website_sale/models/sale_order.py
@@ -114,7 +114,7 @@ class sale_order(osv.Model):
             s = set(j.id for l in (order.website_order_line or []) for j in (l.product_id.accessory_product_ids or []))
             s -= set(l.product_id.id for l in order.order_line)
             product_ids = random.sample(s, min(len(s),3))
-            return self.pool['product.template'].browse(cr, uid, product_ids, context=context)
+            return self.pool['product.product'].browse(cr, uid, product_ids, context=context)
 
 class website(orm.Model):
     _inherit = 'website'
diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml
index 8811f6c90f9c..237f87d0886d 100644
--- a/addons/website_sale/views/templates.xml
+++ b/addons/website_sale/views/templates.xml
@@ -727,14 +727,14 @@
               <tr t-foreach="suggested_products" t-as="product">
 
                   <td>
-                      <a t-attf-href="/shop/product/#{ slug(product) }">
+                      <a t-attf-href="/shop/product/#{ slug(product.product_tmpl_id) }">
                           <span t-field="product.image_small"
                                 t-field-options='{"widget": "image", "class": "img-rounded"}'/>
                       </a>
                   </td>
                   <td>
                       <div>
-                          <a t-attf-href="/shop/product/#{ slug(product) }">
+                          <a t-attf-href="/shop/product/#{ slug(product.product_tmpl_id) }">
                               <strong t-field="product.name"/>
                           </a>
                       </div>
diff --git a/addons/website_sale/views/views.xml b/addons/website_sale/views/views.xml
index 5a1a93105b5a..86e369f11e70 100644
--- a/addons/website_sale/views/views.xml
+++ b/addons/website_sale/views/views.xml
@@ -25,6 +25,7 @@
                     <field name="public_categ_ids" widget="many2many_tags"/>
                     <field name="website_published" class="pull-right" widget="website_button"/>
                     <field name="alternative_product_ids" widget="many2many_tags"/>
+                    <field name="accessory_product_ids" widget="many2many_tags"/>
                     <field name="website_style_ids" widget="many2many_tags"/>
                     <field name="website_sequence"/>
                 </group>
-- 
GitLab