[FIX] web: do not send id in update commands for m2m
When we generate commands for many2many, it could happen that the id was in the list of changed fields (when we are in a new records, with a non empty initial onchange). When this happens, the server is not happy. To reproduce this, open the uninstall wizard of a module in the 'App' application. This creates a new record with a non-empty many2many field. Then click on 'Show technical modules', this will trigger an onchange which should not send the id field.
This commit is contained in:
@@ -2595,6 +2595,7 @@ 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);
|
||||
}
|
||||
@@ -2626,9 +2627,8 @@ var BasicModel = AbstractModel.extend({
|
||||
relRecord = _.findWhere(relRecordAdded, {res_id: list.res_ids[i]});
|
||||
changes = this._generateChanges(relRecord, options);
|
||||
if ('id' in changes) {
|
||||
var id = changes.id;
|
||||
delete changes.id;
|
||||
commands[fieldName].push(x2ManyCommands.update(id, changes));
|
||||
commands[fieldName].push(x2ManyCommands.update(relRecord.res_id, changes));
|
||||
} else {
|
||||
commands[fieldName].push(x2ManyCommands.create(changes));
|
||||
}
|
||||
|
||||
@@ -6633,6 +6633,42 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('default_get, onchange, onchange on m2m', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
this.data.partner.onchanges.int_field = function (obj) {
|
||||
if (obj.int_field === 2) {
|
||||
assert.deepEqual(obj.timmy, [
|
||||
[6, false, [12]],
|
||||
[1, 12, {display_name: 'gold'}]
|
||||
]);
|
||||
}
|
||||
obj.timmy = [
|
||||
[5],
|
||||
[1, 12, {display_name: 'gold'}]
|
||||
];
|
||||
};
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form>' +
|
||||
'<sheet>' +
|
||||
'<field name="timmy">' +
|
||||
'<tree>' +
|
||||
'<field name="display_name"/>' +
|
||||
'</tree>' +
|
||||
'</field>' +
|
||||
'<field name="int_field"/>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
});
|
||||
|
||||
form.$('.o_field_widget[name=int_field]').val(2).trigger('input');
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.module('FieldStatus');
|
||||
|
||||
QUnit.test('static statusbar widget on many2one field', function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user