diff options
| author | Géry Debongnie <ged@odoo.com> | 2018-04-13 16:55:40 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2018-04-13 17:18:10 +0200 |
| commit | 9b2b5eddd4d6feac3926da8242d0b063bb26c9ed (patch) | |
| tree | b596e191731bb720972a5f2c36d1534f6cd33df9 /addons/web/static | |
| parent | dc35d740a6e61487e10a818ee731079faa72af75 (diff) | |
[FIX] web: properly display buttonbox for large screens
In the form view, a new problem appeared since we introduced the extra device
size_class: the buttonbox was folded for large screens, even if there is
only two buttons.
The reason is that the form renderer code used a list to map size class
numbers to the number of buttons allowed to be displayed. With the
extra size class, this number was undefined, which caused an issue.
Diffstat (limited to 'addons/web/static')
| -rw-r--r-- | addons/web/static/src/js/views/form/form_renderer.js | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index d7235587bcf..eb9ea1f5907 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -335,7 +335,7 @@ var FormRenderer = BasicRenderer.extend({ var visible_buttons = buttons_partition[1]; // Get the unfolded buttons according to window size - var nb_buttons = [2, 2, 4, 6, 7][config.device.size_class]; + var nb_buttons = [2, 2, 4, 6][config.device.size_class] || 7; var unfolded_buttons = visible_buttons.slice(0, nb_buttons).concat(invisible_buttons); // Get the folded buttons diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 6c192bff051..0fd60afb402 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -4021,6 +4021,35 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('display correctly buttonbox, in large size class', function (assert) { + assert.expect(1); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<div name="button_box" class="oe_button_box">' + + '<button type="object" class="oe_stat_button" icon="fa-check-square">' + + '<field name="bar"/>' + + '</button>' + + '<button type="object" class="oe_stat_button" icon="fa-check-square">' + + '<field name="foo"/>' + + '</button>' + + '</div>' + + '</form>', + res_id: 2, + config: { + device: {size_class: 5}, + }, + }); + + assert.strictEqual(form.$('.oe_button_box').children().length, 2, + "button box should contain two children"); + + form.destroy(); + }); + QUnit.test('one2many default value creation', function (assert) { assert.expect(1); |
