[FIX] website_sale_options: only one optional product is added to the cart and the...
authorChristophe Matthieu <chm@odoo.com>
Mon, 29 Sep 2014 14:12:57 +0000 (16:12 +0200)
committerChristophe Simonis <chs@odoo.com>
Mon, 27 Oct 2014 09:24:13 +0000 (10:24 +0100)
addons/website_sale/static/src/js/website_sale.js
addons/website_sale_options/static/src/js/website_sale.js
addons/website_sale_options/views/templates.xml

index 34cf1fc..dda494a 100644 (file)
@@ -95,7 +95,7 @@ $('.oe_website_sale').each(function () {
         $parent.find(".oe_default_price:first .oe_currency_value").html( price_to_str(+$(this).data('lst_price')) );
         $parent.find(".oe_price:first .oe_currency_value").html(price_to_str(+$(this).data('price')) );
 
-        var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img, img.product_detail_img');
+        var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img:first, img.product_detail_img');
         $img.attr("src", "/website/image/product.product/" + $(this).val() + "/image");
     });
 
@@ -129,7 +129,7 @@ $('.oe_website_sale').each(function () {
         }
 
         if (product_id) {
-            var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img, img.product_detail_img');
+            var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img:first, img.product_detail_img');
             $img.attr("src", "/website/image/product.product/" + product_id + "/image");
             $img.parent().attr('data-oe-model', 'product.product').attr('data-oe-id', product_id)
                 .data('oe-model', 'product.product').data('oe-id', product_id);
index 72a4513..3d8ecee 100644 (file)
@@ -53,7 +53,7 @@ $(document).ready(function () {
                             $(".js_remove .js_items").addClass("hidden");
                             $(".js_remove .js_item").removeClass("hidden");
                         } else {
-                            $(".js_remove .js_items").removeClass("hidden").text($(".js_remove .js_items").text().replace(/[0-9.,]+/, qty));
+                            $(".js_remove .js_items").removeClass("hidden").text($(".js_remove .js_items:first").text().replace(/[0-9.,]+/, qty));
                             $(".js_remove .js_item").addClass("hidden");
                         }
                     });
@@ -65,5 +65,14 @@ $(document).ready(function () {
                 });
             return false;
         });
-
+    
+    
+    $('#cart_products input.js_quantity').change(function () {
+        var value = $(this).val();
+        var $next = $(this).closest('tr').next('.optional_product');
+        while($next.length) {
+            $next.find('.js_quantity').text(value);
+            $next = $next.next('.optional_product');
+        }
+    });
 });
index 1f0a430..2963666 100644 (file)
                     <a href="#" class="js_remove"><small>Remove from cart</small></a>
                   </span>
                 </td>
+                <t t-set="option_inc" t-value="option_inc+1"/>
               </tr>
 
             </tbody>