summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-04-23 08:29:34 +0200
committerGéry Debongnie <ged@odoo.com>2017-04-24 10:20:34 +0200
commitae1a30e618e071877a561377f544934ee2a89417 (patch)
tree56bf049c7e2cbc5c114c38078f98173342dd06e3 /addons/web/static/src
parente4bf1f1ccc522f1715dba82940d5bb647e5138e3 (diff)
[FIX] web: use correct id when using form buttons
With new records, it could happen that clicking on a button in the header was followed by actions using the wrong id. This was caused by a field name="id" in the view (see sale order view, in the delivery.view_order_form_with_carrier inherited view). In that case, the id was registered in the changes list, and caused invalid data in the record: its data.id was set to null.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js6
1 files changed, 4 insertions, 2 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 e737df9cc9e..efc7fbc1971 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -662,6 +662,10 @@ var BasicModel = AbstractModel.extend({
}
var shouldReload = 'reload' in options ? options.reload : true;
var method = self.isNew(record_id) ? 'create' : 'write';
+ if (record._changes) {
+ // id never changes, and should not be written
+ delete record._changes.id;
+ }
var changes = self._generateChanges(record);
if (method === 'create') {
@@ -673,8 +677,6 @@ var BasicModel = AbstractModel.extend({
}
});
}
- // make sure we don't write an undefined id
- delete changes.id;
// in the case of a write, only perform the RPC if there are changes to save
if (method === 'create' || Object.keys(changes).length) {