[FIX] web: prevent crash in some cases (o2m)
Recent works in the orm (see [1] for example) changed the behaviour of the server in the case of onchanges: it tries to optimize Odoo by sending a minimal diff to the web client in onchanges. Concretely, this means that the web client receives commands 4 (link to) instead of command 1 (update + record data). It also sends a minimal diff in that case. This is a big issue for the web client, because it relied on the knowledge of the data from the command 1 to be able to evaluate some modifiers. The good news is that we can mitigate the issue in one case: we do not actually need to evaluate the modifiers in the case of a command 4 (comming from the server), because we can assume that the record is valid. So, we simply bypass the check in that case. Note that this should fix most of the problem, but a deeper problem still remains: a crash can still happen when an onchange modifies a record in a one2many (but in a different page), and we also have a modifier which needs to be evaluated. opw: #1904514 [1] https://github.com/odoo/odoo/pull/29086 closes odoo/odoo#29172 closes odoo/odoo#29086
This commit is contained in:
committed by
Raphael Collet
parent
a8f4b522a3
commit
e062f89ed5
@@ -3208,6 +3208,7 @@ var BasicModel = AbstractModel.extend({
|
||||
_.each(element._changes, function (command) {
|
||||
if (command.operation === 'DELETE' ||
|
||||
command.operation === 'FORGET' ||
|
||||
(command.operation === 'ADD' && !command.isNew)||
|
||||
command.operation === 'REMOVE_ALL') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6207,6 +6207,51 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('one2many, onchange, edition and multipage...', function (assert) {
|
||||
assert.expect(7);
|
||||
|
||||
this.data.partner.onchanges = {
|
||||
turtles: function (obj) {
|
||||
obj.turtles = [[5]].concat(obj.turtles);
|
||||
}
|
||||
};
|
||||
|
||||
this.data.partner.records[0].turtles = [1,2,3];
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:'<form string="Partners">' +
|
||||
'<field name="turtles">' +
|
||||
'<tree editable="bottom" limit="2">' +
|
||||
'<field name="turtle_foo"/>' +
|
||||
'</tree>' +
|
||||
'</field>' +
|
||||
'</form>',
|
||||
res_id: 1,
|
||||
mockRPC: function (route, args) {
|
||||
assert.step(args.method + ' ' + args.model)
|
||||
return this._super(route, args);
|
||||
},
|
||||
viewOptions: {
|
||||
mode: 'edit',
|
||||
},
|
||||
});
|
||||
form.$('.o_field_x2many_list_row_add a').click();
|
||||
form.$('.o_field_x2many_list_row_add a').click();
|
||||
|
||||
assert.verifySteps([
|
||||
'read partner',
|
||||
'read turtle',
|
||||
'default_get turtle',
|
||||
'onchange partner',
|
||||
'default_get turtle',
|
||||
'onchange partner',
|
||||
]);
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('one2many with CREATE onchanges correctly refreshed', function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user