summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-04-05 12:15:49 +0200
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit4872c8da31bc10738c0f195c8665b59ec61f0e42 (patch)
tree17d825b942b4eda58aa1123f9e9d7f8d2a8ae2b3 /addons/web/static/src/js/views/basic/basic_model.js
parent97c6dc77925090cb57e57b9edabcf81c93bea87c (diff)
[FIX] web: don't save readonly fields
Readonly fields can be modified with onchanges, but they should not be saved.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js
index ced26fb7cb2..304f7e475f7 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -612,6 +612,15 @@ var BasicModel = AbstractModel.extend({
// make sure we don't write an undefined id
delete changes.id;
+ // remove readonly fields from the list of changes
+ if (method === 'write') {
+ for (var fieldName in changes) {
+ if (record.fields[fieldName].readonly) {
+ delete changes[fieldName];
+ }
+ }
+ }
+
// in the case of a write, only perform the RPC if there are changes to save
if (method === 'create' || Object.keys(changes).length) {
var args = method === 'write' ? [[record.data.id], changes] : [changes];