summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-08-30 10:38:53 +0200
committerAaron Bohy <aab@odoo.com>2017-08-30 12:29:47 +0200
commitf1082f15525ccf42b1fb95fb7da0211eaf64fcb9 (patch)
tree452c0aca5662fe2602fb3a873175c218e95cfcee /addons/web/static/src/js/views/basic
parent96b1db4cd44ab70c5a7014ee36a8b475e1c5e38a (diff)
[FIX] web: don't send virtual id on save
The problem occurred on form views with an x2many field with a default value containing CREATE commands, i.e. when opening such a form view in create mode, the x2many field is pre-filled with some (non-existing yet) subrecords. If the user then edited those subrecords, and then clicked on 'Save' to create the main record, an 'UPDATE' command was sent alongside the 'CREATE' one for the x2many, and the id of the 'UPDATE' command was a virtual id (as the subrecord didn't exist yet), and it crashed. This could happen in MRP: - Enable lots in Iventory - Choose a product which is a component of another (through mrp bom) - Set this product as tracked by lot - Set this product inventory quantity to 0 - Create a new manufacturing order for the product for which it is a component - Click on "Check Availability" - click on Produce: the many2many already contains a subrecord - edit the lot field of that subrecord - click on 'Record Production'
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js5
1 files changed, 4 insertions, 1 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 9dc544ba84f..4e3e5823223 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -2407,7 +2407,10 @@ var BasicModel = AbstractModel.extend({
_.each(list._changes, function (change) {
if (change.operation === 'ADD') {
relRecordAdded.push(self.localData[change.id]);
- } else if (change.operation === 'UPDATE') {
+ } else if (change.operation === 'UPDATE' && !self.isNew(change.id)) {
+ // ignore new records that would have been updated
+ // afterwards, as all their changes would already
+ // be aggregated in the CREATE command
relRecordUpdated.push(self.localData[change.id]);
}
});