summaryrefslogtreecommitdiff
path: root/addons/website_sale/static/src/js/website_sale_payment.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website_sale/static/src/js/website_sale_payment.js')
-rw-r--r--addons/website_sale/static/src/js/website_sale_payment.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/addons/website_sale/static/src/js/website_sale_payment.js b/addons/website_sale/static/src/js/website_sale_payment.js
new file mode 100644
index 00000000..4d6abd98
--- /dev/null
+++ b/addons/website_sale/static/src/js/website_sale_payment.js
@@ -0,0 +1,48 @@
+odoo.define('website_sale.payment', function (require) {
+'use strict';
+
+var publicWidget = require('web.public.widget');
+
+publicWidget.registry.WebsiteSalePayment = publicWidget.Widget.extend({
+ selector: '#wrapwrap:has(#checkbox_cgv)',
+ events: {
+ 'change #checkbox_cgv': '_onCGVCheckboxClick',
+ },
+
+ /**
+ * @override
+ */
+ start: function () {
+ this.$checkbox = this.$('#checkbox_cgv');
+ this.$payButton = $('button#o_payment_form_pay');
+ this.$checkbox.trigger('change');
+ return this._super.apply(this, arguments);
+ },
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ _adaptPayButton: function () {
+ var disabledReasons = this.$payButton.data('disabled_reasons') || {};
+ disabledReasons.cgv = !this.$checkbox.prop('checked');
+ this.$payButton.data('disabled_reasons', disabledReasons);
+
+ this.$payButton.prop('disabled', _.contains(disabledReasons, true));
+ },
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ _onCGVCheckboxClick: function () {
+ this._adaptPayButton();
+ },
+});
+});