From a529a928b4a295d5a834bcd8ab9a02433be6ff6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 4 Apr 2017 16:22:58 +0200 Subject: [PATCH] [REF] web: prevent useless rerender in some cases When clicking on a form button, the saveRecord method is called, which will then call the toReadonlymode method, which will rerender the form view, even if it was already in readonly mode. --- addons/web/static/src/js/views/form/form_controller.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index 7de919a0c2c..498fb29453b 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -368,8 +368,10 @@ var FormController = BasicController.extend({ * @private */ _toReadOnlyMode: function () { - this.$el.removeClass('o_form_editable'); - this.update({mode: "readonly"}, {reload: false}); + if (this.mode !== 'readonly') { + this.$el.removeClass('o_form_editable'); + this.update({mode: "readonly"}, {reload: false}); + } }, /** * Updates the controller's title according to the new state