[FIX] website_sale, website_sale_delivery, delivery: price computation on quantity change
bzr revid: dle@openerp.com-20140425152541-qiabb4sa7y2skgql
This commit is contained in:
parent
22edf72dc1
commit
b54e49b291
|
@ -194,9 +194,9 @@ class delivery_grid(osv.osv):
|
||||||
for line in order.order_line:
|
for line in order.order_line:
|
||||||
if not line.product_id or line.is_delivery:
|
if not line.product_id or line.is_delivery:
|
||||||
continue
|
continue
|
||||||
total += line.price_subtotal or 0.0
|
|
||||||
weight += (line.product_id.weight or 0.0) * line.product_uom_qty
|
weight += (line.product_id.weight or 0.0) * line.product_uom_qty
|
||||||
volume += (line.product_id.volume or 0.0) * line.product_uom_qty
|
volume += (line.product_id.volume or 0.0) * line.product_uom_qty
|
||||||
|
total = order.amount_total or 0.0
|
||||||
|
|
||||||
|
|
||||||
return self.get_price_from_picking(cr, uid, id, total,weight, volume, context=context)
|
return self.get_price_from_picking(cr, uid, id, total,weight, volume, context=context)
|
||||||
|
|
|
@ -406,14 +406,16 @@ class Ecommerce(http.Controller):
|
||||||
order.amount_total,
|
order.amount_total,
|
||||||
request.website._render("website_sale.total", {'website_sale_order': order})]
|
request.website._render("website_sale.total", {'website_sale_order': order})]
|
||||||
|
|
||||||
@http.route(['/shop/set_cart_json/'], type='json', auth="public")
|
@http.route(['/shop/set_cart_json/'], type='json', auth="public", website=True, multilang=True)
|
||||||
def set_cart_json(self, path=None, product_id=None, order_line_id=None, set_number=0, json=None):
|
def set_cart_json(self, path=None, product_id=None, order_line_id=None, set_number=0, json=None):
|
||||||
quantity = request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
|
quantity = request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
|
||||||
product_id=product_id, order_line_id=order_line_id, set_number=set_number,
|
product_id=product_id, order_line_id=order_line_id, set_number=set_number,
|
||||||
context=request.context)
|
context=request.context)
|
||||||
order = self.get_order()
|
order = self.get_order()
|
||||||
return [quantity,
|
return [quantity,
|
||||||
order.get_number_of_products()]
|
order.get_number_of_products(),
|
||||||
|
order.amount_total,
|
||||||
|
request.website._render("website_sale.total", {'website_sale_order': order})]
|
||||||
|
|
||||||
@http.route(['/shop/checkout/'], type='http', auth="public", website=True, multilang=True)
|
@http.route(['/shop/checkout/'], type='http', auth="public", website=True, multilang=True)
|
||||||
def checkout(self, **post):
|
def checkout(self, **post):
|
||||||
|
|
|
@ -20,18 +20,20 @@ $(document).ready(function () {
|
||||||
.fadeIn(600);
|
.fadeIn(600);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".oe_website_sale .oe_mycart input.js_quantity").change(function () {
|
$(".oe_website_sale .oe_mycart input.js_quantity").change(function (ev) {
|
||||||
var $input = $(this);
|
var $input = $(this);
|
||||||
|
var $link = $(ev.currentTarget);
|
||||||
var value = parseInt($input.val(), 10);
|
var value = parseInt($input.val(), 10);
|
||||||
if (isNaN(value)) value = 0;
|
if (isNaN(value)) value = 0;
|
||||||
openerp.jsonRpc("/shop/set_cart_json/", 'call', {'order_line_id': $input.data('id'), 'set_number': value})
|
openerp.jsonRpc("/shop/set_cart_json/", 'call', {'order_line_id': $input.data('id'), 'set_number': value})
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
if (!data) {
|
if (!data[0]) {
|
||||||
location.reload();
|
location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
set_my_cart_quantity(data[1]);
|
set_my_cart_quantity(data[1]);
|
||||||
$input.val(data[0]);
|
$link.parents(".input-group:first").find(".js_quantity").val(data[0]);
|
||||||
|
$('#mycart_total').replaceWith(data[3]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,10 @@ class SaleOrder(orm.Model):
|
||||||
carrier_id = delivery_id
|
carrier_id = delivery_id
|
||||||
break
|
break
|
||||||
order.write({'carrier_id': carrier_id}, context=context)
|
order.write({'carrier_id': carrier_id}, context=context)
|
||||||
if carrier_id:
|
if carrier_id:
|
||||||
order.delivery_set(context=context)
|
order.delivery_set(context=context)
|
||||||
else:
|
else:
|
||||||
order._delivery_unset(context=context)
|
order._delivery_unset(context=context)
|
||||||
|
|
||||||
return bool(carrier_id)
|
return bool(carrier_id)
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,5 @@ class Website(orm.Model):
|
||||||
product_id=product_id, order_line_id=order_line_id, number=number, set_number=set_number,
|
product_id=product_id, order_line_id=order_line_id, number=number, set_number=set_number,
|
||||||
context=context)
|
context=context)
|
||||||
order = self.ecommerce_get_current_order(cr, uid, context=context)
|
order = self.ecommerce_get_current_order(cr, uid, context=context)
|
||||||
return self.pool['sale.order']._check_carrier_quotation(cr, uid, order, force_carrier_id=None, context=context) and quantity or None
|
self.pool['sale.order']._check_carrier_quotation(cr, uid, order, force_carrier_id=None, context=context) and quantity or None
|
||||||
|
return quantity
|
||||||
|
|
Loading…
Reference in New Issue