diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2020-09-03 15:19:26 +0000 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2020-09-04 11:51:31 +0000 |
| commit | 0e12fa135882cd5095dbf15fe2f64231c6a84336 (patch) | |
| tree | aab11c62659c2b15e045031672aaa08dd130d26f | |
| parent | 789ec45b43bb8f36bb5be65fcb2ef46119fd0acf (diff) | |
[FIX] web: avoid displaying noContentHelper after kanban quick_create
Have a kanban with a filter
Quick create a record in one column that won't match the domain
Before this commit, the noContent helper was displayed. This was because
the count of the group was reset to zero after the web_read_group call.
After this commit, the noContent helper is not displayed.
Note that in the quick_create situation, the records are not re-fetched
i.e. there is no search_read after the read_group.
Task-id 2251734
closes odoo/odoo#57066
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 8 | ||||
| -rw-r--r-- | addons/web/static/tests/views/kanban_tests.js | 54 |
2 files changed, 62 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 24373e3b753..5be80268cc6 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -4602,6 +4602,14 @@ var BasicModel = AbstractModel.extend({ // sub-groups // Also keep data if we only reload groups' own data updatedProps.data = oldGroup.data; + if (options.onlyGroups) { + // keep count and res_ids as in this case the group + // won't be search_read again. This situation happens + // when using kanban quick_create where the record is manually + // added to the datapoint before getting here. + updatedProps.res_ids = oldGroup.res_ids; + updatedProps.count = oldGroup.count; + } } _.extend(newGroup, updatedProps); // set the limit such that all previously loaded records diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js index 56f37a82a23..386ff3cdadc 100644 --- a/addons/web/static/tests/views/kanban_tests.js +++ b/addons/web/static/tests/views/kanban_tests.js @@ -3728,6 +3728,60 @@ QUnit.module('Views', { kanban.destroy(); }); + QUnit.test('nocontent helper after adding a record (kanban with progressbar)', async function (assert) { + assert.expect(3); + + const kanban = await createView({ + View: KanbanView, + model: 'partner', + data: this.data, + arch: `<kanban > + <field name="product_id"/> + <progressbar field="foo" colors='{"yop": "success", "gnap": "warning", "blip": "danger"}' sum_field="int_field"/> + <templates> + <t t-name="kanban-box"> + <div><field name="foo"/></div> + </t> + </templates> + </kanban>`, + groupBy: ['product_id'], + domain: [['foo', '=', 'abcd']], + mockRPC: function (route, args) { + if (args.method === 'web_read_group') { + const result = { + groups: [ + { __domain: [['product_id', '=', 3]], product_id_count: 0, product_id: [3, 'hello'] }, + ], + }; + return Promise.resolve(result); + } + return this._super.apply(this, arguments); + }, + viewOptions: { + action: { + help: "No content helper", + }, + }, + }); + + assert.containsOnce(kanban, '.o_view_nocontent', "the nocontent helper is displayed"); + + // add a record + await testUtils.dom.click(kanban.$('.o_kanban_quick_add')); + await testUtils.fields.editInput(kanban.$('.o_kanban_quick_create .o_input'), 'twilight sparkle'); + await testUtils.dom.click(kanban.$('button.o_kanban_add')); + + assert.containsNone(kanban, '.o_view_nocontent', + "the nocontent helper is not displayed after quick create"); + + // cancel quick create + await testUtils.dom.click(kanban.$('button.o_kanban_cancel')); + assert.containsNone(kanban, '.o_view_nocontent', + "the nocontent helper is not displayed after cancelling the quick create"); + + kanban.destroy(); + }); + QUnit.test('if view was not grouped at start, it can be grouped and ungrouped', async function (assert) { assert.expect(3); |
