[MERGE] from master
authorChristophe Matthieu <chm@odoo.com>
Fri, 13 Jun 2014 10:35:23 +0000 (12:35 +0200)
committerChristophe Matthieu <chm@odoo.com>
Fri, 13 Jun 2014 10:35:23 +0000 (12:35 +0200)
1  2 
addons/product/product.py
addons/website_sale/static/src/js/website_sale.js
addons/website_sale/views/views.xml

Simple merge
@@@ -110,55 -110,15 +110,54 @@@ $(document).ready(function () 
          });
  
          if (product_id) {
 -            $(".oe_price_h4").removeClass("hidden");
 -            $(".oe_not_available").addClass("hidden");
 +            $parent.removeClass("css_not_available");
 +            $porduct_id.val(product_id);
 +            $parent.find(".js_check_product").removeAttr("disabled");
          } else {
 -            $(".oe_price_h4").addClass("hidden");
 -            $(".oe_not_available").removeClass("hidden");
 -            $form_var.find('input[name="product_id"]').val(0);
 -            $form_var.find(".a-submit").attr("disabled", "disabled");
 +            $parent.addClass("css_not_available");
 +            $porduct_id.val(0);
 +            $parent.find(".js_check_product").attr("disabled", "disabled");
          }
      });
 -    $form_var.find("input:first").trigger('change');
 +    $('ul.js_add_cart_variants').each(function () {
 +        $('input.js_variant_change, select.js_variant_change', this).first().trigger('change');
 +    });
 +
 +    $("a.js_add, a.js_remove").click(function (event) {
 +        event.preventDefault();
 +        var $parent = $(this).parents('.js_product:first');
 +        $parent.find("a.js_add, span.js_remove").toggleClass("hidden");
 +        $parent.find("input.js_optional_same_quantity").val( $(this).hasClass("js_add") ? 1 : 0 );
 +    });
 +
 +    $('#product_detail form[action^="/shop/cart/update"] .a-submit').off("click").click(function (event) {
 +        event.preventDefault();
 +        var $link = $(this);
 +        var $form = $link.parents("form:first");
 +        var quantity = parseInt($('input[name="add_qty"]').val() || 1, 10);
 +        var defs = [];
 +        $link.attr('disabled', 'disabled');
 +        $('.js_product', $form).each(function () {
 +            var product_id = parseInt($('input.optional_product_id', this).val(),10);
 +            var qty = parseInt($('input.js_quantity', this).val(),10);
 +            if($('input.js_optional_same_quantity', this).val() !== '0') {
 +                qty = quantity;
 +            }
 +            if (product_id && qty) {
 +                defs.push(openerp.jsonRpc("/shop/cart/update_json", 'call', {
 +                    'line_id': null,
 +                    'product_id': product_id,
 +                    'add_qty': qty,
 +                    'display': false}));
 +            }
 +        });
 +        $.when.apply($.when, defs).then(function () {
 +            if ($link.hasClass("js_goto_shop")) {
 +                $form.prepend('<input type="hidden" name="goto_shop" value="1"/>');
 +            }
 +            $form.submit();
 +        });
 +        return false;
 +    });
  
  });
Simple merge