From 8bbb2caaad8ef452a2554bb56e94483ecfb2657a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20De=20Andr=C3=A9s?= Date: Thu, 7 Sep 2023 16:14:47 +0200 Subject: [PATCH] [16.0][FIX] website_sale_cart_expire: Protect _setExpirationDate assignment error Added format check before setting the datetime in str_to_datetime in order to avoid error message in website. It checks "/shop/cart/get_expire_date" url to retrieve the information, but when it's installed some module that restricts the access to some url (like website_require_login) it retrieves HTML from the redirection. Function evaluates "expireDate" as string and tries to convert it to datetime, but it's not a date so raises throws error. Now checks if the string has a valid format date before try to convert it otherwise sets "expireDate" to undefined. --- .../static/src/js/website_sale_cart_expire.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website_sale_cart_expire/static/src/js/website_sale_cart_expire.js b/website_sale_cart_expire/static/src/js/website_sale_cart_expire.js index a78b39bffc..1fc4f489e3 100644 --- a/website_sale_cart_expire/static/src/js/website_sale_cart_expire.js +++ b/website_sale_cart_expire/static/src/js/website_sale_cart_expire.js @@ -44,8 +44,10 @@ odoo.define("website_sale_cart_expire", (require) => { * @param {String|Date} expireDate */ _setExpirationDate: function (expireDate) { - if (typeof expireDate === "string") { + if (typeof expireDate === "string" && !isNaN(Date.parse(expireDate))) { expireDate = time.str_to_datetime(expireDate); + }else{ + expireDate = undefined; } this.expireDate = expireDate ? moment(expireDate) : false; },