[FIX] website_sale: image doesn't change when the user select a product (for product...
authorDenis Ledoux <dle@odoo.com>
Mon, 20 Oct 2014 16:40:06 +0000 (18:40 +0200)
committerDenis Ledoux <dle@odoo.com>
Mon, 20 Oct 2014 16:40:06 +0000 (18:40 +0200)
addons/website_sale/static/src/js/website_sale.js
addons/website_sale_options/static/src/js/website_sale.js

index e86897c..34cf1fc 100644 (file)
@@ -94,6 +94,9 @@ $('.oe_website_sale').each(function () {
         var $parent = $(this).closest('.js_product');
         $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');
+        $img.attr("src", "/website/image/product.product/" + $(this).val() + "/image");
     });
 
     $(oe_website_sale).on('change', 'input.js_variant_change, select.js_variant_change', function (ev) {
@@ -126,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');
+            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');
             $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 c0dba9e..72a4513 100644 (file)
@@ -5,15 +5,18 @@ $(document).ready(function () {
         .click(function (event) {
             var $form = $(this).closest('form');
             var quantity = parseFloat($form.find('input[name="add_qty"]').val() || 1);
+            var product_id = parseInt($form.find('input[type="hidden"][name="product_id"], input[type="radio"][name="product_id"]:checked').first().val(),10);
             event.preventDefault();
             openerp.jsonRpc("/shop/modal", 'call', {
-                    'product_id': parseInt($form.find('input[name="product_id"]').val(),10),
+                    'product_id': product_id,
                     kwargs: {
                        context: openerp.website.get_context()
                     },
                 }).then(function (modal) {
                     var $modal = $(modal);
 
+                    $modal.find('img:first').attr("src", "/website/image/product.product/" + product_id + "/image");
+
                     $modal.appendTo($form)
                         .modal()
                         .on('hidden.bs.modal', function () {