diff options
| author | Nasreddin (bon) <bon@odoo.com> | 2020-10-19 11:59:41 +0000 |
|---|---|---|
| committer | Nasreddin (bon) <bon@odoo.com> | 2020-10-20 10:19:20 +0000 |
| commit | 7e54d9aa6b6a955200e7002b143848de0c3a093e (patch) | |
| tree | 08d0ef25eb84172743f17c6e8a3983133df8a395 /addons/payment/static | |
| parent | 978cd02406495e7566cefb556276e2ac2292e3f8 (diff) | |
[FIX] payment: User can pay without selecting a delivery method
Issue
- Install "eCommerce" and "Inventoy"
- Activate "Fedex" delivery connector in settings
- Publish "Free Delivery" and "Fedex US" delivery method
- Put the "FedEx" one above the "Free Delivery"
- Go to shop and add an item to cart
- Set an adress with no ZIP code and checkout
- Select a payment methode and pay
Order is generated without selecting a delivery method
Same behavior happend when using only "Fedex" as delivery
method.
Cause
The flow make the `payment.payment_form` trigger start after
`website_sale_delivery.checkout` JS module.
In 'start' function of `payment.payment_form`, the `disabled`
attribut is removed from button if no checkbox_cgv is present
and therefore break the `disabling` managemet since
`disabledReasons` payButton data are not sync anymore.
Solution
Remove 'disabled' attribut only if has `disabledReasons` data on
payButton (checkbox_cgv feature alter `disabledReasons`).
opw-2355407
opw-2357605
closes odoo/odoo#60355
X-original-commit: 04e589e80b3ef48640f275cb20d31c17c2126c69
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
Diffstat (limited to 'addons/payment/static')
| -rw-r--r-- | addons/payment/static/src/js/payment_form.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index 67ac150e10a..2138082f1de 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -22,9 +22,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ * @override */ start: function () { - if(!$('#checkbox_cgv').length){ - $("#o_payment_form_pay").removeAttr('disabled'); - } + this._adaptPayButton(); var self = this; return this._super.apply(this, arguments).then(function () { self.options = _.extend(self.$el.data(), self.options); @@ -148,6 +146,11 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ } return e.message.data.arguments[0]; }, + _adaptPayButton: function () { + var $payButton = $("#o_payment_form_pay"); + var disabledReasons = $payButton.data('disabled_reasons') || {}; + $payButton.prop('disabled', _.contains(disabledReasons, true)); + }, //-------------------------------------------------------------------------- // Handlers |
