[FIX] web: kanban quick create: fix raise condition

Let's assume a kanban view using a custom form view to quick
create record:
  <kanban on_create="quick_create" quick_create_view="view_ref">

Before this commit, there was a raise condition that could lead
to a crash. For instance, click to quick create a record in a
given column, and while the form view is loading, fold the column.

Issue reported on task 2323196

closes odoo/odoo#57322

X-original-commit: 9fed69b9e0e13652fd17e9a7c7c8dd838e2f22ed
Signed-off-by: Michaël Mattiello <mcm-odoo@users.noreply.github.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2020-09-09 07:59:13 +00:00
parent dbe6b1b30d
commit 4e61415994
2 changed files with 52 additions and 1 deletions
@@ -8,6 +8,7 @@ odoo.define('web.kanban_record_quick_create', function (require) {
var core = require('web.core');
var QuickCreateFormView = require('web.QuickCreateFormView');
const session = require('web.session');
var Widget = require('web.Widget');
var RecordQuickCreate = Widget.extend({
@@ -69,7 +70,7 @@ var RecordQuickCreate = Widget.extend({
var formView = new QuickCreateFormView(fieldsViews.form, {
context: self.context,
modelName: self.model,
userContext: self.getSession().user_context,
userContext: session.user_context,
});
return formView.getController(self).then(function (controller) {
self.controller = controller;
@@ -2334,6 +2334,56 @@ QUnit.module('Views', {
kanban.destroy();
});
QUnit.test('close a column while quick creating a record', async function (assert) {
assert.expect(6);
const def = testUtils.makeTestPromise();
const kanban = await createView({
View: KanbanView,
model: 'partner',
data: this.data,
arch: `
<kanban on_create="quick_create" quick_create_view="some_view_ref">
<templates><t t-name="kanban-box">
<div><field name="foo"/></div>
</t></templates>
</kanban>`,
archs: {
'partner,some_view_ref,form': '<form><field name="int_field"/></form>',
},
groupBy: ['product_id'],
async mockRPC(route, args) {
const result = this._super(...arguments);
if (args.method === 'load_views') {
await def;
}
return result;
},
});
assert.containsN(kanban, '.o_kanban_group', 2);
assert.containsNone(kanban, '.o_column_folded');
// click to quick create a new record in the first column (this operation is delayed)
await testUtils.dom.click(kanban.$('.o_kanban_group:first .o_kanban_quick_add'));
assert.containsNone(kanban, '.o_form_view');
// click to fold the first column
await testUtils.kanban.toggleGroupSettings(kanban.$('.o_kanban_group:first'));
await testUtils.dom.click(kanban.$('.o_kanban_group:first .o_kanban_toggle_fold'));
assert.containsOnce(kanban, '.o_column_folded');
def.resolve();
await testUtils.nextTick();
assert.containsNone(kanban, '.o_form_view');
assert.containsOnce(kanban, '.o_column_folded');
kanban.destroy();
});
QUnit.test('quick create record: open on a column while another column has already one', async function (assert) {
assert.expect(6);