From b00ec7eb790e4b23580a9310f4945a2bfbd63f36 Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Fri, 5 Apr 2024 10:29:05 +0200 Subject: [PATCH] [FIX] web: add fallback to Object.hasOwn in patch function The patch function was changed at commit [1]. This introduced a call to `Object.hasOwn` which is the preferred way to check if an Object has a property as its own. However, after multiple user reports, it seems like a significant amount of user and website visitors still use browsers that do not have Object.hasOwn implemented. This commit adds a polyfill to add Obejct.hasOwn in case it is not found. [1]: https://github.com/odoo/odoo/commit/04fddc19d4aedd8105e0fda5582288c2bb1833fe Fixes https://github.com/odoo/odoo/issues/142022 opw-3824593 Part-of: odoo/odoo#160758 --- addons/web/__manifest__.py | 1 + addons/web/static/src/polyfills/object.js | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 addons/web/static/src/polyfills/object.js diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index d4dea87752c..7015f7cebcf 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -123,6 +123,7 @@ This module provides the core of the Odoo Web Client. 'web/static/src/start.js', ], 'web.assets_frontend_minimal': [ + 'web/static/src/polyfills/object.js', 'web/static/src/module_loader.js', 'web/static/src/session.js', 'web/static/src/core/browser/cookie.js', diff --git a/addons/web/static/src/polyfills/object.js b/addons/web/static/src/polyfills/object.js new file mode 100644 index 00000000000..a8f0790fe28 --- /dev/null +++ b/addons/web/static/src/polyfills/object.js @@ -0,0 +1,3 @@ +if (!Object.hasOwn) { + Object.hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key); +}