summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-10-17 16:29:35 +0200
committerGéry Debongnie <ged@odoo.com>2017-10-17 18:21:47 +0200
commitd365a289d4ed3f557fa46155419f5f517860fe9c (patch)
treea8d14194533d813abcdc2328e423b95c025143a7 /addons/web/static/tests/fields/relational_fields_tests.js
parenta1e15b9fced014e58185b161b80eb34692b1474a (diff)
[FIX] web: generate proper x2many commands in some cases
When creating a new record with a non empty default value for a one2many field, we did send the command 0 (for each one2many line) instead of the command 1 (update). This was a pretty big problem, because then the server would try to create a line with possibly incomplete data. For example, it was not possible to create expense sheets: go to expense menu, select one expense in the list view, click on the action menu 'submit to manager', this opens a form view with a one2many with the selected expense, then save. Before this commit, this would lead to a server error.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index 5d5e22e386e..5677443aa0f 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -1062,14 +1062,14 @@ QUnit.module('relational_fields', {
});
QUnit.test('list in form: default_get with x2many create and onchange', function (assert) {
- assert.expect(1);
+ assert.expect(2);
this.data.partner.onchanges.turtles = function (obj) {
assert.deepEqual(
obj.turtles,
[
- [0, false, {turtle_foo: 'blip', id: 2}],
- [0, false, {turtle_foo: 'kawa', id: 3}]
+ [1, 2, {turtle_foo: 'blip'}],
+ [1, 3, {turtle_foo: 'kawa'}]
],
"should have properly created the x2many command list");
};
@@ -1092,10 +1092,21 @@ QUnit.module('relational_fields', {
if (args.method === 'default_get') {
return $.when({turtles: [[6, 0, [2,3]]]});
}
+ if (args.method === 'create') {
+ // it would be even better if we did not send the current
+ // unchanged state with the command 1, but this seems more
+ // difficult.
+ assert.deepEqual(args.args[0].turtles, [
+ [1, 2, {turtle_foo: 'blip'}],
+ [1, 3, {turtle_foo: 'kawa'}]
+ ], 'should send proper commands to create method');
+ }
return this._super.apply(this, arguments);
},
});
+ form.$buttons.find('.o_form_button_save').click();
+
form.destroy();
});