diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-04-27 16:44:03 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-28 08:28:57 +0200 |
| commit | c5579ef89e2a595893d0959bef6fddfdbfb6d697 (patch) | |
| tree | ebd78e96460ffae40bad4465d04f66ee8f179488 /addons/web/static/tests | |
| parent | 627da0503bae048a5ad9905a798d951a3be1a611 (diff) | |
[FIX] web: FormRenderer: notebook and invisible pages
When switching between records, the active tab of the previous
record is made active on the new record.
However, before this rev., this was done without checking that
this tab is still visible on the new record (there may be an
invisible attrs that makes it invisible), so it happened that
the active tab was actually invisible.
This was for instance the case when switching between stock
pickings, as the first tab ('Operations') is sometimes hidden.
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index ae989f26165..f59c484b3c9 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -3778,5 +3778,53 @@ QUnit.module('Views', { form.destroy(); }); + + QUnit.test('do not activate an hidden tab when switching between records', function (assert) { + assert.expect(6); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form string="Partners">' + + '<sheet>' + + '<notebook>' + + '<page string="Foo" attrs=\'{"invisible": [["id", "=", 2]]}\'>' + + '<field name="foo"/>' + + '</page>' + + '<page string="Bar">' + + '<field name="bar"/>' + + '</page>' + + '</notebook>' + + '</sheet>' + + '</form>', + viewOptions: { + ids: [1, 2], + index: 0, + }, + res_id: 1, + }); + + assert.strictEqual(form.$('.o_notebook ul li:not(.o_form_invisible)').length, 2, + "both tabs should be visible"); + assert.ok(form.$('.o_notebook ul li:first').hasClass('active'), + "first tab should be active"); + + // click on the pager to switch to the next record + form.pager.$('.o_pager_next').click(); + assert.strictEqual(form.$('.o_notebook ul li:not(.o_form_invisible)').length, 1, + "only the second tab should be visible"); + assert.ok(form.$('.o_notebook ul li:not(.o_form_invisible)').hasClass('active'), + "the visible tab should be active"); + + // click on the pager to switch back to the previous record + form.pager.$('.o_pager_previous').click(); + assert.strictEqual(form.$('.o_notebook ul li:not(.o_form_invisible)').length, 2, + "both tabs should be visible again"); + assert.ok(form.$('.o_notebook ul li:nth(1)').hasClass('active'), + "second tab should be active"); + + form.destroy(); + }); }); }); |
