From 3aee5a4cb40f924fb978aed5b0cea10f3dede6e2 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 11 Dec 2019 10:00:21 +0000 Subject: [PATCH] [FIX] web: utils: patch: restore _super Before this rev., this._super wasn't correctly reset after being called. It means that it was sometimes wrongly set, for instance in the following scenario: utils.patch(SomeComponent, { x: function () { this.y(); this._super(...arguments); // this._super was still y }, y: function () { this._super(...arguments); }, }); closes odoo/odoo#41691 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/core/utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js index 4fe1740d6eb..6527207dfc9 100644 --- a/addons/web/static/src/js/core/utils.js +++ b/addons/web/static/src/js/core/utils.js @@ -549,8 +549,11 @@ var utils = { metadata.origMethods[methodName] = original; } proto[methodName] = function (...args) { + const previousSuper = this._super; this._super = original; - return method.call(this, ...args); + const res = method.call(this, ...args); + this._super = previousSuper; + return res; }; } });