Skip to content

Commit

Permalink
[FIX] website_sale: image doesn't change when the user select a produ…
Browse files Browse the repository at this point in the history
…ct (for product variant list). website_sale_options: image dones't change in modal with the selection
  • Loading branch information
beledouxdenis committed Oct 20, 2014
1 parent 285ba3d commit bfb61cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion addons/website_sale/static/src/js/website_sale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion addons/website_sale_options/static/src/js/website_sale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit bfb61cd

Please sign in to comment.