[FIX] website_sale: terms & conditions

- Install website_sale and website_sale_delivery
- Activate 'Terms & Condition' on the payment page
- Process a shopping cart

On the payment page, the 'Terms & Condition' checkbox is unchecked, but
the 'Payment' button is enabled.

Both `$checkbox.change` and `_onCarrierUpdateAnswer` set the `disabled`
property, and conflict.

We keep on the HTML node an object with the list of disabled reasons.

opw-1923459

Co-authored-by: Nicolas Lempereur <nle@odoo.com>

closes odoo/odoo#30504
This commit is contained in:
Nicolas Martinelli
2019-01-25 10:19:12 +00:00
co-authored by Nicolas Lempereur
parent fe36bff420
commit b2266fae87
2 changed files with 8 additions and 2 deletions
@@ -7,9 +7,12 @@ var $checkbox = $("#checkbox_cgv");
if (!$checkbox.length) {
return;
}
var $pay_button = $('button#o_payment_form_pay');
$checkbox.on('change', function (ev) {
$('button#o_payment_form_pay').prop('disabled', !ev.target.checked);
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
$pay_button.data('disabled_reasons').cgv = !ev.target.checked;
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
});
$checkbox.change();
});
@@ -35,7 +35,8 @@ odoo.define('website_sale_delivery.checkout', function (require) {
$carrier_badge.children('span').text(result.new_amount_delivery);
$carrier_badge.removeClass('d-none');
$compute_badge.addClass('d-none');
$pay_button.prop('disabled', false);
$pay_button.data('disabled_reasons').carrier_selection = false;
$pay_button.prop('disabled', _.contains($pay_button.data('disabled_reasons'), true));
}
else {
console.error(result.error_message);
@@ -48,6 +49,8 @@ odoo.define('website_sale_delivery.checkout', function (require) {
};
var _onCarrierClick = function(ev) {
$pay_button.data('disabled_reasons', $pay_button.data('disabled_reasons') || {});
$pay_button.data('disabled_reasons').carrier_selection = true;
$pay_button.prop('disabled', true);
var carrier_id = $(ev.currentTarget).val();
var values = {'carrier_id': carrier_id};