From ebd17217c4e7e9ff06d97028de64fb2fc44d6266 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 8 Jun 2017 15:37:04 +0200 Subject: [FIX] web: BasicModel: don't write on readonly fields Ultimately, it seems that sending the value of readonly fields when saving is not such a good idea. Suppose that there is a computed field displayed as readonly in a form view. This field is computed from other records, e.g. from a one2many field which is editable in the form view. Finally, the inverse function of the computed field creates the one2many records. If the user adds some records to the one2many, then saves, the readonly computed field's value is sent to the server as well, and thus the inverse function is executed, which isn't what we want. This commit essentially reverts 0494d61274, except that we now take into account the readonly modifier to determine whether or not a value is sent to the server, and not only the readonly attribute of the field (which can be seen as a default). Before rev. 0494d61274, we made a difference between write and create RPCs, for an unclear reason. We don't do that anymore: readonly fields are never sent to the server (same behavior as before the new views). --- addons/web/static/src/js/views/basic/basic_controller.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 16a066db495..af4ca7d7a08 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -419,6 +419,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { var saveDef = this.model.save(recordID, { // Save then leave edit mode reload: options.reload, savePoint: options.savePoint, + viewType: options.viewType, }); if (!options.stayInEdit) { saveDef = saveDef.then(function (fieldNames) { -- cgit v1.2.3