Added Upstream Patch for website_sale_delivery
This commit is contained in:
parent
3712c502ce
commit
b40e3903f2
@ -67,8 +67,15 @@ class WebsiteSaleDelivery(WebsiteSale):
|
||||
return {'status': order.delivery_rating_success,
|
||||
'error_message': order.delivery_message,
|
||||
'carrier_id': carrier_id,
|
||||
'new_amount_delivery': float_repr(currency.round(order.delivery_price), currency.decimal_places),
|
||||
'new_amount_untaxed': order.amount_untaxed,
|
||||
'new_amount_tax': order.amount_tax,
|
||||
'new_amount_total': order.amount_total,
|
||||
'new_amount_delivery': self._format_amount(order.delivery_price, currency),
|
||||
'new_amount_untaxed': self._format_amount(order.amount_untaxed, currency),
|
||||
'new_amount_tax': self._format_amount(order.amount_tax, currency),
|
||||
'new_amount_total': self._format_amount(order.amount_total, currency),
|
||||
}
|
||||
|
||||
def _format_amount(self, amount, currency):
|
||||
fmt = "%.{0}f".format(currency.decimal_places)
|
||||
lang = request.env['res.lang']._lang_get(request.env.context.get('lang') or 'en_US')
|
||||
|
||||
return lang.format(fmt, currency.round(amount), grouping=True, monetary=True)\
|
||||
.replace(r' ', u'\N{NO-BREAK SPACE}').replace(r'-', u'\u2011')
|
||||
|
@ -65,6 +65,7 @@ class SaleOrder(models.Model):
|
||||
carrier = delivery
|
||||
break
|
||||
self.write({'carrier_id': carrier.id})
|
||||
self._remove_delivery_line()
|
||||
if carrier:
|
||||
self.get_delivery_price()
|
||||
if self.delivery_rating_success:
|
||||
|
@ -27,6 +27,10 @@ flectra.define('website_sale_delivery.checkout', function (require) {
|
||||
else {
|
||||
console.error(result.error_message);
|
||||
$compute_badge.text(result.error_message);
|
||||
$amount_delivery.text(result.new_amount_delivery);
|
||||
$amount_untaxed.text(result.new_amount_untaxed);
|
||||
$amount_tax.text(result.new_amount_tax);
|
||||
$amount_total.text(result.new_amount_total);
|
||||
}
|
||||
};
|
||||
|
||||
@ -40,6 +44,12 @@ flectra.define('website_sale_delivery.checkout', function (require) {
|
||||
|
||||
var $carriers = $("#delivery_carrier input[name='delivery_type']");
|
||||
$carriers.click(_onCarrierClick);
|
||||
// Workaround to:
|
||||
// - update the amount/error on the label at first rendering
|
||||
// - prevent clicking on 'Pay Now' if the shipper rating fails
|
||||
if ($carriers.length > 0) {
|
||||
$carriers.filter(':checked').click();
|
||||
}
|
||||
|
||||
/* Handle stuff */
|
||||
$(".oe_website_sale select[name='shipping_id']").on('change', function () {
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
<template id="cart_delivery" name="Delivery Costs" inherit_id="website_sale.total">
|
||||
<xpath expr="//div[@id='order_total_untaxed']" position="before">
|
||||
<div class="row" id="order_delivery" t-if="website_sale_order and website_sale_order.has_delivery">
|
||||
<div class="row" id="order_delivery" t-if="website_sale_order and website_sale_order.carrier_id">
|
||||
<span class="col-xs-6 text-right text-muted" title="Delivery will be updated after choosing a new delivery method"> Delivery:</span>
|
||||
<span class="col-xs-6 text-right-not-xs text-left-xs text-muted">
|
||||
<span t-field="website_sale_order.amount_delivery" style="white-space: nowrap;" t-options='{
|
||||
|
Loading…
Reference in New Issue
Block a user