summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-07-17 15:50:43 +0200
committerGéry Debongnie <ged@odoo.com>2017-07-18 14:45:22 +0200
commit5f8dea490acd1812cb7d920ef793cf414014e296 (patch)
treefab87b5dc433af9c20db0a35fa402a81f41fd2c2 /addons/web/static/tests/fields/relational_fields_tests.js
parentcb863ed0bb72d9df3eeb412ac0cf57662438c25e (diff)
[FIX] web: properly display id in some cases
When a one2many is set through an onchange, the web client did not set the id field properly. Because of that, it could not be displayed in a list. This is due to the fact that the id is given in the command like this: [1, 53, {...}] Here, the command is 1 (update), then 53 (id), then some values, which do not have the id. So, in this specific case, we assumed that all the new values were in the object, even though we properly set the res_id property. We fix this issue at the root: in the _makeDataPoint method, we make sure that no datapoint can be created with a res_id and without the corresponding id key. Note that this issue was not found in a standard installation of Odoo (but it may be present somewhere), but in some custom code. It is rare to actually use the id field in a view, but in this case, we had a many2many in kanban view, and the id was used to format the url of an image.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index aacbb744252..026026906c4 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -3652,6 +3652,34 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('id in one2many obtained in onchange is properly set', function (assert) {
+ assert.expect(1);
+
+ this.data.partner.onchanges.turtles = function (obj) {
+ obj.turtles = [
+ [5],
+ [1, 3, {turtle_foo: "kawa"}]
+ ];
+ };
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="turtles">' +
+ '<tree>' +
+ '<field name="id"/>' +
+ '<field name="turtle_foo"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ });
+
+ assert.strictEqual(form.$('tr.o_data_row').text(), '3kawa',
+ "should have properly displayed id and foo field");
+ form.destroy();
+ });
+
QUnit.test('sub form view with a required field', function (assert) {
assert.expect(2);
this.data.partner.fields.foo.required = true;