Browse files

[FIX] web: close m2o (in o2m) dialog with ESCAPE

Let's assume a one2many editable list containing a many2one field
(e.g. in a sales order, the product_id m2o in order_line o2m), and
the scenario where the user clicks on 'Create and Edit' in the o2m,
and then presses ESCAPE in the opened dialog.

Before this rev., it crashed because the 'navigation_move' (cancel)
event wasn't stop propagated by the form renderer (the one of the
dialog), and thus bubbled up to the list editable renderer, which
asked its basic model to discard a record it didn't know.

Note: same fix as in 8445baa (done in saas-11.3), but with a
simpler test.

Task 1878254
  • Loading branch information...
aab-odoo committed Oct 11, 2018
1 parent 4aec0b7 commit a78108318606a0709d40c4849e45b0788d2954a1
@@ -947,9 +947,7 @@ var FormRenderer = BasicRenderer.extend({
* @param {OdooEvent} ev
_onNavigationMove: function (ev) {
if ( !== "cancel") {
var index;
if ( === "next") {
@@ -5546,7 +5546,7 @@ QUnit.module('relational_fields', {
QUnit.test('pressing enter in a o2m with a required empty m2o', function (assert) {
QUnit.test('pressing enter in a o2m with a required empty field', function (assert) {
assert.expect(4); = true;
@@ -9819,6 +9819,50 @@ QUnit.module('relational_fields', {
QUnit.test('create and edit on m2o in o2m, and press ESCAPE', function (assert) {
var form = createView({
View: FormView,
model: 'partner',
arch: '<form>' +
'<field name="turtles">' +
'<tree editable="top">' +
'<field name="turtle_trululu"/>' +
'</tree>' +
'</field>' +
archs: {
'partner,false,form': '<form><field name="display_name"/></form>',
form.$('.o_field_x2many_list_row_add a').click();
assert.strictEqual(form.$('.o_selected_row').length, 1,
"should have create a new row in edition");
var $input = form.$('.o_field_widget[name="turtle_trululu"] input');
assert.strictEqual($('.modal .o_form_view').length, 1,
"should have opened a form view in a dialog");
$('.modal .o_form_view .o_field_widget[name=display_name]').trigger($.Event('keydown', {
which: $.ui.keyCode.ESCAPE,
keyCode: $.ui.keyCode.ESCAPE,
assert.strictEqual($('.modal .o_form_view').length, 0,
"should have closed the dialog");
assert.strictEqual(form.$('.o_selected_row').length, 1,
"new row should still be present");
QUnit.test('many2many kanban: edition', function (assert) {

0 comments on commit a781083

Please sign in to comment.