[IMP] website_sale: Skip overload with requests
Until the request to get the unit price is not finished, no request is sent to the server. issue #4298
This commit is contained in:
parent
78420d1cf2
commit
4d7671a4c3
|
@ -41,10 +41,14 @@ $('.oe_website_sale').each(function () {
|
||||||
$(ev.currentTarget).parents(".thumbnail").toggleClass("disabled");
|
$(ev.currentTarget).parents(".thumbnail").toggleClass("disabled");
|
||||||
});
|
});
|
||||||
|
|
||||||
$(oe_website_sale).on("change", ".oe_cart input.js_quantity", function (event) {
|
$(oe_website_sale).find(".oe_cart input.js_quantity").on("change", function () {
|
||||||
var $input = $(this);
|
var $input = $(this);
|
||||||
|
if ($input.data('update_change')) {
|
||||||
|
console.log($input.val()+ "+++");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var value = parseInt($input.val(), 10);
|
var value = parseInt($input.val(), 10);
|
||||||
var $dom = $(event.target).closest('tr');
|
var $dom = $(this).closest('tr');
|
||||||
var default_price = parseFloat($dom.find('.text-danger > span.oe_currency_value').text());
|
var default_price = parseFloat($dom.find('.text-danger > span.oe_currency_value').text());
|
||||||
var $dom_optional = $dom.nextUntil(':not(.optional_product.info)');
|
var $dom_optional = $dom.nextUntil(':not(.optional_product.info)');
|
||||||
var line_id = parseInt($input.data('line-id'),10);
|
var line_id = parseInt($input.data('line-id'),10);
|
||||||
|
@ -54,6 +58,7 @@ $('.oe_website_sale').each(function () {
|
||||||
product_ids.push($(this).find('span[data-product-id]').data('product-id'));
|
product_ids.push($(this).find('span[data-product-id]').data('product-id'));
|
||||||
});
|
});
|
||||||
if (isNaN(value)) value = 0;
|
if (isNaN(value)) value = 0;
|
||||||
|
$input.data('update_change', true);
|
||||||
openerp.jsonRpc("/shop/get_unit_price", 'call', {
|
openerp.jsonRpc("/shop/get_unit_price", 'call', {
|
||||||
'product_ids': product_ids,
|
'product_ids': product_ids,
|
||||||
'add_qty': value,
|
'add_qty': value,
|
||||||
|
@ -74,6 +79,12 @@ $('.oe_website_sale').each(function () {
|
||||||
'product_id': parseInt($input.data('product-id'),10),
|
'product_id': parseInt($input.data('product-id'),10),
|
||||||
'set_qty': value})
|
'set_qty': value})
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
|
$input.data('update_change', false);
|
||||||
|
if (value !== parseInt($input.val(), 10)) {
|
||||||
|
console.log($input.val()+ "***");
|
||||||
|
$input.trigger('change');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!data.quantity) {
|
if (!data.quantity) {
|
||||||
location.reload();
|
location.reload();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue