summaryrefslogtreecommitdiff
path: root/addons/website_sale/static/src/js/website_sale_payment.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website_sale/static/src/js/website_sale_payment.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
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();
+ },
+});
+});