[FIX] website_sale: Pick the right shipping method on order confirmation
Steps to reproduce: - Enable different shipment methods (eg. Fedex US, USPS, DHLS US). - Enable the 'Wire transfer' payment provider. - Go to website, choose a storable product and checkout. - On the last step of checkout, just click on 'Pay' Issue: The delivery method and cost is not the that was initially selected on the checkout page. Reason: On the start of the ``websiteSaleDelivery`` widget, we try to initialize the shipping cost of every shipping methods in the list. But the we make a call on ``/shop/update_carrier`` which not only gives the shipping cost but also change the delivery method of the order. As the loop is async, the last random carrier to be computed is the one on the sale order when validating. So if we don't click on the shipping method we want(to update the carrier) it will that last one which will be used. Solution: Use the ``/shop/carrier_rate_shipment`` which only returns a result with the cost without touching the sale order. opw-3457396 closes odoo/odoo#133846 X-original-commit: 7e2682b903b7908f0e86f66603e34d0b6fe90e52 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> Signed-off-by: Eteil Junior Djoumatchoua (etdj) <etdj@odoo.com>
This commit is contained in:
@@ -39,7 +39,7 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
await this._getCurrentLocation();
|
||||
await this.carriers.forEach(async (carrierInput) => {
|
||||
this._showLoading((carrierInput));
|
||||
await this._handleCarrierUpdateResult(carrierInput)
|
||||
await this._getCarrierRateShipment(carrierInput);
|
||||
});
|
||||
if (this._super && typeof(this._super.apply)==="function") {
|
||||
return this._super.apply(this, arguments);
|
||||
@@ -117,6 +117,21 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
*/
|
||||
_updateShippingCost: function(amount) {
|
||||
core.bus.trigger('update_shipping_cost', amount);
|
||||
},
|
||||
/**
|
||||
* Get the rate shipment of a carrier
|
||||
*
|
||||
* @private
|
||||
* @params {Object} carrier: The carrier element
|
||||
*/
|
||||
_getCarrierRateShipment: async function(carrierInput) {
|
||||
const result = await this._rpc({
|
||||
route: '/shop/carrier_rate_shipment',
|
||||
params: {
|
||||
'carrier_id': carrierInput.value,
|
||||
}
|
||||
});
|
||||
this._handleCarrierUpdateResultBadge(result);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user