summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-11-12 14:06:16 +0000
committerNicolas Martinelli <nim@odoo.com>2020-11-12 17:39:42 +0000
commit9fe5950ed191bca5f952ea00faa2cb20b980435f (patch)
tree55ba218cdddef10e405100a3977cbb4f2f2e4a50
parentebbb3de1e5f363689a5ba1647bb4c26416e42d5b (diff)
[FIX] website_sale_delivery: free delivery with free product
- Install eCommerce - Website > Products - Create a product with a Sales Price of 0 and publish it - Website > Configuration - Enable "Shipping Costs" - Go to Configuration / eCommerce / Shipping Methods - Create a new method with a fixed price of zero - Go to the ecommerce - Add the free product of in the cart - Process Checkout A traceback appears. It happens because the 'Pay' button: https://github.com/odoo/odoo/blob/b64a7924044f012da49db178b6c02fdf9b47bc5c/addons/payment/views/payment_templates.xml#L149-L158 is replaced by: https://github.com/odoo/odoo/blob/b64a7924044f012da49db178b6c02fdf9b47bc5c/addons/website_sale/views/templates.xml#L1401-L1409 Since `$payButton.data('disabled_reasons')` is `undefined`, a crash occurs. We make the code more robust by using the same logic than: https://github.com/odoo/odoo/blob/b64a7924044f012da49db178b6c02fdf9b47bc5c/addons/website_sale/static/src/js/website_sale_payment.js#L30-L32 opw-2380774 closes odoo/odoo#61689 X-original-commit: 3ba37c70c84b8651a544fbaf45dbfb5bc85bdbed Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
-rw-r--r--addons/website_sale_delivery/static/src/js/website_sale_delivery.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/addons/website_sale_delivery/static/src/js/website_sale_delivery.js b/addons/website_sale_delivery/static/src/js/website_sale_delivery.js
index 883a45ff5f8..07bcdb5e9d6 100644
--- a/addons/website_sale_delivery/static/src/js/website_sale_delivery.js
+++ b/addons/website_sale_delivery/static/src/js/website_sale_delivery.js
@@ -28,8 +28,9 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
if ($carriers.length > 0) {
if ($carriers.filter(':checked').length === 0) {
$payButton.prop('disabled', true);
- $payButton.data('disabled_reasons', $payButton.data('disabled_reasons') || {});
- $payButton.data('disabled_reasons').carrier_selection = true;
+ var disabledReasons = $payButton.data('disabled_reasons') || {};
+ disabledReasons.carrier_selection = true;
+ $payButton.data('disabled_reasons', disabledReasons);
}
$carriers.filter(':checked').click();
}
@@ -76,7 +77,9 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
$amountUntaxed.html(result.new_amount_untaxed);
$amountTax.html(result.new_amount_tax);
$amountTotal.html(result.new_amount_total);
- $payButton.data('disabled_reasons').carrier_selection = false;
+ var disabledReasons = $payButton.data('disabled_reasons') || {};
+ disabledReasons.carrier_selection = false;
+ $payButton.data('disabled_reasons', disabledReasons);
$payButton.prop('disabled', _.contains($payButton.data('disabled_reasons'), true));
} else {
$amountDelivery.html(result.new_amount_delivery);
@@ -120,8 +123,9 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
$radio.prop("checked", true);
var $payButton = $('#o_payment_form_pay');
$payButton.prop('disabled', true);
- $payButton.data('disabled_reasons', $payButton.data('disabled_reasons') || {});
- $payButton.data('disabled_reasons').carrier_selection = true;
+ var disabledReasons = $payButton.data('disabled_reasons') || {};
+ disabledReasons.carrier_selection = true;
+ $payButton.data('disabled_reasons', disabledReasons);
dp.add(this._rpc({
route: '/shop/update_carrier',
params: {