diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-06-02 11:03:40 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-06-07 08:08:49 +0200 |
| commit | 98142f731d38aecf87d7e7900e6eeff8c047a9eb (patch) | |
| tree | e039be4c032564936fd9b28525ea606db4cb15ee /addons/web/static/tests/views/basic_model_tests.js | |
| parent | 6f3eada2c3a5c0a21c9b3fef3bef3f655b0892e4 (diff) | |
[FIX] web: BasicModel: default_get: fetch x2manys of x2manys
Suppose that a default_get returns the value [[6, 0, [1]] for an
x2many field (i.e. put id 1 in the relation). A read is performed
to fetch record of the comodel whose id is 1. Suppose that there
is another x2many field of the comodel. This x2many has to be
fetched (if not empty), and processed by the BasicModel (i.e. a
dataPoint must be created for it) as well.
Before this rev., the second x2many wasn't fetched nor processed,
and it produced a traceback for example in Expenses app, when
clicking on 'Submit to manager' from an expense form view.
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/basic_model_tests.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js index 582e06ba62b..fefc7231e5b 100644 --- a/addons/web/static/tests/views/basic_model_tests.js +++ b/addons/web/static/tests/views/basic_model_tests.js @@ -1165,6 +1165,54 @@ QUnit.module('Views', { model.destroy(); }); + QUnit.test('default_get: fetch x2manys inside x2manys', function (assert) { + assert.expect(3); + + this.data.partner.fields.o2m = { + string: "O2M", type: 'one2many', relation: 'partner', default: [[6, 0, [1]]], + }; + + var model = createModel({ + Model: BasicModel, + data: this.data, + }); + + var params = { + fieldNames: ['o2m'], + fields: this.data.partner.fields, + fieldsInfo: { + form: { + o2m: { + relatedFields: this.data.partner.fields, + fieldsInfo: { + list: { + category: { + relatedFields: { display_name: {} }, + }, + }, + }, + viewType: 'list', + }, + }, + }, + modelName: 'partner', + type: 'record', + viewType: 'form', + }; + + model.load(params).then(function (resultID) { + var record = model.get(resultID); + assert.strictEqual(record.data.o2m.count, 1, "o2m field should contain 1 record"); + var categoryList = record.data.o2m.data[0].data.category; + assert.strictEqual(categoryList.count, 1, + "category field should contain 1 record"); + assert.strictEqual(categoryList.data[0].data.display_name, + 'gold', "category records should have been fetched"); + }); + + model.destroy(); + }); + QUnit.test('contexts and domains can be properly fetched', function (assert) { assert.expect(8); @@ -1448,6 +1496,7 @@ QUnit.module('Views', { fieldsInfo: { form: { product_ids: { + relatedFields: this.data.product.fields, fieldsInfo: { list: { name: {}, date: {} } }, viewType: 'list', } |
