summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorStéphane Bidoul (ACSONE) <stephane.bidoul@acsone.eu>2017-12-31 15:43:49 +0100
committerGéry Debongnie <ged@odoo.com>2018-01-03 13:22:09 +0100
commitbb10cd50c28f224146634365ac341de6e09644d3 (patch)
treea68c793db71959e945e22a0f81183939f18cb008 /addons/web/static/src/js/views/basic/basic_model.js
parent29af3c0610a90fe7172244883eba291a27d734e9 (diff)
[FIX] web: issue with id field in x2m form
When the 'id' field is present in a x2m form, the x2m actions generated on create of the parent object are incorrect.
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.js6
1 files changed, 3 insertions, 3 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 1562bffdc42..2baafc52514 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -95,11 +95,13 @@ var x2ManyCommands = {
// (0, _, {values})
CREATE: 0,
create: function (values) {
+ delete values.id;
return [x2ManyCommands.CREATE, false, values];
},
// (1, id, {values})
UPDATE: 1,
update: function (id, values) {
+ delete values.id;
return [x2ManyCommands.UPDATE, id, values];
},
// (2, id[, _])
@@ -2625,7 +2627,6 @@ var BasicModel = AbstractModel.extend({
_.each(relRecordUpdated, function (relRecord) {
var changes = self._generateChanges(relRecord, options);
if (!_.isEmpty(changes)) {
- delete changes.id;
var command = x2ManyCommands.update(relRecord.res_id, changes);
commands[fieldName].push(command);
}
@@ -2645,7 +2646,6 @@ var BasicModel = AbstractModel.extend({
relRecord = _.findWhere(relRecordUpdated, {res_id: list.res_ids[i]});
changes = relRecord ? this._generateChanges(relRecord, options) : {};
if (!_.isEmpty(changes)) {
- delete changes.id;
command = x2ManyCommands.update(relRecord.res_id, changes);
didChange = true;
} else {
@@ -2656,7 +2656,7 @@ var BasicModel = AbstractModel.extend({
// this is a new id (maybe existing in DB, but new in JS)
relRecord = _.findWhere(relRecordAdded, {res_id: list.res_ids[i]});
changes = this._generateChanges(relRecord, options);
- if ('id' in changes) {
+ if (changes.id) {
// the subrecord already exists in db
delete changes.id;
if (this.isNew(record.id)) {