[FIX] web: fix issue of notebook page with invisiblity modifier
before this commit: when there is only one page in the notebook tag and there is a boolean field in form to show/hide that notebook page based on invisibility attrs, if we toggle boolean field notebook hides, that's OK but when we toggle boolean field again then notebook page is displayed but it is not active and due to that content of notebook page is not displayed. after this commit: when there is only one page in notebook and it has attrs for invisibilty, when we toggle boolean field to hide/show notebook page then notebook page as well as content is toggled. task-2449053 closes odoo/odoo#66582 X-original-commit: a0b5ecd344d6ac79d8e4d194cfabf3d639259c73 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -1000,6 +1000,13 @@ var FormRenderer = BasicRenderer.extend({
|
||||
tab.$page.removeClass('active');
|
||||
self.inactiveNotebooks.push(renderedTabs);
|
||||
}
|
||||
if (!modifiers.invisible) {
|
||||
// make first page active if there is only one page to display
|
||||
var $visibleTabs = $headers.find('li:not(.o_invisible_modifier)');
|
||||
if ($visibleTabs.length === 1) {
|
||||
self.inactiveNotebooks.push(renderedTabs);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -875,6 +875,44 @@ QUnit.module('Views', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('invisible attrs on notebook page which has only one page', async function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
var form = await createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<field name="bar"/>' +
|
||||
'<notebook>' +
|
||||
'<page string="Foo" attrs=\'{"invisible": [["bar", "!=", false]]}\'>' +
|
||||
'<field name="foo"/>' +
|
||||
'</page>' +
|
||||
'</notebook>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
res_id: 1,
|
||||
viewOptions: {
|
||||
mode: 'edit',
|
||||
},
|
||||
});
|
||||
|
||||
assert.notOk(form.$('.o_notebook .nav .nav-link:first()').hasClass('active'),
|
||||
'first tab should not be active');
|
||||
assert.ok(form.$('.o_notebook .nav .nav-item:first()').hasClass('o_invisible_modifier'),
|
||||
'first tab should be invisible');
|
||||
|
||||
// enable checkbox
|
||||
await testUtils.dom.click(form.$('.o_field_boolean input'));
|
||||
assert.ok(form.$('.o_notebook .nav .nav-link:first()').hasClass('active'),
|
||||
'first tab should be active');
|
||||
assert.notOk(form.$('.o_notebook .nav .nav-item:first()').hasClass('o_invisible_modifier'),
|
||||
'first tab should be visible');
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('first notebook page invisible', async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user