From c168d032c00e5c1dcb331143ff443352c54ab6c4 Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Tue, 30 May 2023 14:11:24 +0000 Subject: [PATCH] [FIX] website_sale: max value for product per page Entering a value greater than that allowed by a 32-bit integer raises an error Steps to reproduce: 1. Install eCommerce 2. Open the website and go to the 'Shop' page 3. Open the editor and click on any product in the grid 4. Set the value of the 'Number Of Products' to an integer greater than 2147483647 5. An error is raised Solution: Limit the number of product per page to 10000. This will have the effect of avoiding the `NumericValueOutOfRange` error but will also prevent the user to load too much products at once to avoid a timeout. opw-3226154 closes odoo/odoo#124158 X-original-commit: f620e95b5e459551f881a9aec2bc75b45b9d354e Signed-off-by: Guillaume Merlin (megu) --- addons/website_sale/static/src/js/website_sale.editor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.editor.js b/addons/website_sale/static/src/js/website_sale.editor.js index ae8f6cff0fa..05d0d454c03 100644 --- a/addons/website_sale/static/src/js/website_sale.editor.js +++ b/addons/website_sale/static/src/js/website_sale.editor.js @@ -230,15 +230,16 @@ options.registry.WebsiteSaleGridLayout = options.Class.extend({ * @see this.selectClass for params */ setPpg: function (previewMode, widgetValue, params) { + const PPG_LIMIT = 10000; const ppg = parseInt(widgetValue); if (!ppg || ppg < 1) { return false; } - this.ppg = ppg; + this.ppg = Math.min(ppg, PPG_LIMIT); return this._rpc({ route: '/shop/config/website', params: { - 'shop_ppg': ppg, + 'shop_ppg': this.ppg, }, }); },