[FIX] web: hang when saving then discarding
When editing a record, if it cannot be saved (b.e. due to required fields) and the user clicks on save, then on discard Before this fix, the window did nothing (seems like it is unresponsive) After this fix, the user is able to discard the form. task-id: 1937142 closes odoo/odoo#30871
This commit is contained in:
@@ -188,12 +188,18 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
|
||||
// mutex-protected as commitChanges function of x2m has to be aware of
|
||||
// all final changes made to a row.
|
||||
var self = this;
|
||||
this.savingDef = this.mutex.getUnlockedDef().then(function () {
|
||||
return self.renderer.commitChanges(recordID || self.handle).then(function () {
|
||||
var savingDef = $.Deferred();
|
||||
this.savingDef = savingDef;
|
||||
|
||||
return this.mutex.getUnlockedDef()
|
||||
.then(function () {
|
||||
return self.renderer.commitChanges(recordID || self.handle);
|
||||
})
|
||||
.then(function () {
|
||||
return self.mutex.exec(self._saveRecord.bind(self, recordID, options));
|
||||
});
|
||||
});
|
||||
return this.savingDef;
|
||||
})
|
||||
.then(savingDef.resolve.bind(savingDef))
|
||||
.fail(savingDef.resolve.bind(savingDef));
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
|
||||
@@ -16,7 +16,6 @@ var Widget = require('web.Widget');
|
||||
|
||||
var _t = core._t;
|
||||
var createView = testUtils.createView;
|
||||
var createActionManager = testUtils.createActionManager;
|
||||
var createAsyncView = testUtils.createAsyncView;
|
||||
var createActionManager = testUtils.createActionManager;
|
||||
|
||||
@@ -106,6 +105,14 @@ QUnit.module('Views', {
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
this.actions = [{
|
||||
id: 1,
|
||||
name: 'Partners Action 1',
|
||||
res_model: 'partner',
|
||||
type: 'ir.actions.act_window',
|
||||
views: [[false, 'kanban'], [false, 'form']],
|
||||
}];
|
||||
}
|
||||
}, function () {
|
||||
|
||||
@@ -7518,6 +7525,37 @@ QUnit.module('Views', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('discard after a failed save', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var actionManager = createActionManager({
|
||||
data: this.data,
|
||||
archs: {
|
||||
'partner,false,form': '<form>' +
|
||||
'<field name="date" required="true"/>' +
|
||||
'<field name="foo" required="true"/>' +
|
||||
'</form>',
|
||||
'partner,false,kanban': '<kanban><templates><t t-name="kanban-box">' +
|
||||
'</t></templates></kanban>',
|
||||
'partner,false,search': '<search></search>',
|
||||
},
|
||||
actions: this.actions,
|
||||
});
|
||||
|
||||
actionManager.doAction(1);
|
||||
|
||||
testUtils.dom.click('.o_control_panel .o-kanban-button-new');
|
||||
|
||||
//cannot save because there is a required field
|
||||
testUtils.dom.click('.o_control_panel .o_form_button_save');
|
||||
testUtils.dom.click('.o_control_panel .o_form_button_cancel');
|
||||
|
||||
assert.containsNone(actionManager, '.o_form_view');
|
||||
assert.containsOnce(actionManager, '.o_kanban_view');
|
||||
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.module('FormViewTABMainButtons');
|
||||
|
||||
QUnit.test('using tab in an empty required string field should not move to the next field',function(assert) {
|
||||
|
||||
Reference in New Issue
Block a user