From 6f44b789545c9ff158a4e8e0d2c497a15600a7e7 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Wed, 10 Apr 2024 16:30:12 +0200 Subject: [PATCH] [FIX] website_payment: fix "Donation" snippet "Pre-Filled Options" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to Reproduce : - Install eCommerce. - Drag and drop the "Donation" snippet. - Click on the prices in the snippet. - Toggle the "Pre-Filled Options" option. - => There is a traceback. This bug is due to the fact that since commit [1], all templates have been added to the OWL app. With OWL, a t-foreach in a template can no longer loop over a 0 number and causes an error if we try to. This is what happens here, as toggling off the "Pre-filled Options" option sets the donationAmounts to 0, which is then used in a loop in the templates. This commit fixes this by replacing the number by an empty array, so the loop cannot fail. [1]: https://github.com/odoo/odoo/commit/4703e4a2efa9213979307e4d3dedeedc61ad0fc3 task-3859207 closes odoo/odoo#161431 Signed-off-by: Soukéina Bojabza (sobo) --- .../website_payment/static/src/snippets/s_donation/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_payment/static/src/snippets/s_donation/options.js b/addons/website_payment/static/src/snippets/s_donation/options.js index 3582dc96d2a..a6a92c35582 100644 --- a/addons/website_payment/static/src/snippets/s_donation/options.js +++ b/addons/website_payment/static/src/snippets/s_donation/options.js @@ -289,7 +289,7 @@ options.registry.Donation = options.Class.extend({ this.$target.find('.s_donation_donate_btn').before(sliderTemplate); } const prefilledOptions = this.$target[0].dataset.prefilledOptions; - let donationAmounts = 0; + let donationAmounts = []; let showDescriptions = false; if (prefilledOptions) { donationAmounts = JSON.parse(this.$target[0].dataset.donationAmounts);