diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2017-11-13 11:14:07 +0100 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2017-11-21 13:31:56 +0100 |
| commit | 5c9f4fd67d37b088dd9453d06351310210497b6e (patch) | |
| tree | d2d4529738b14c776df8c2fcdb0a3f3e3f911d0e /addons/web/static/tests/fields/basic_fields_tests.js | |
| parent | 4de48320cac5450db8c881b9f410d812c4f7748c (diff) | |
[FIX] web: fieldDependency should be in fields too
Commit f45edfbe6d03b15977392dda9561cd7a3e16ce34 fixed a bug on image fields
but was a partial fix.
The problem is that while adding field dependencies to fieldsInfo,
it did not add them in the fields of the view, making the view crash.
After this commit, views and subviews contain fieldDependency as both info and actual fields of the view
OPW 780021, 781620, 779649
[FIX] web: tests on many2many subviews
closes #20891
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 30e5d477882..ef555868e94 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1496,6 +1496,55 @@ QUnit.module('basic_fields', { }); + QUnit.test('image fields in subviews are loaded correctly', function (assert) { + assert.expect(5); + + this.data.partner.records[0].__last_update = '2017-02-08 10:00:00'; + this.data.partner.records[0].document = 'myimage'; + this.data.partner_type.fields.image = {name: 'image', type: 'binary'}; + this.data.partner_type.records[0].image = 'product_image'; + this.data.partner.records[0].timmy = [12]; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners">' + + '<field name="document" widget="image" options="{\'size\': [90, 90]}"/>' + + '<field name="timmy" widget="many2many">' + + '<tree>' + + '<field name="display_name"/>' + + '</tree>' + + '<form>' + + '<field name="image" widget="image"/>' + + '</form>' + + '</field>' + + '</form>', + res_id: 1, + mockRPC: function (route, args) { + if (route === 'data:image/png;base64,myimage') { + assert.step("The view's image should have been fetched"); + return $.when('wow'); + } + return this._super.apply(this, arguments); + }, + }); + assert.verifySteps(["The view's image should have been fetched"]); + + assert.strictEqual(form.$('tr.o_data_row').length, 1, + 'There should be one record in the many2many'); + + // Actual flow: click on an element of the m2m to get its form view + form.$('tbody td:contains(gold)').click(); + assert.strictEqual($('.modal-dialog').length, 1, + 'The modal should have opened'); + assert.strictEqual($('.modal-dialog').find('.o_field_image > img')[0].src, + 'data:image/png;base64,product_image', + 'The image of the many2many in its form view should be present'); + + form.destroy(); + }); + QUnit.module('JournalDashboardGraph'); QUnit.test('graph dashboard widget is rendered correctly', function (assert) { |
