[FIX] web_editor: prevent crash with FieldTextHtmlSimple
If the method commitChange from the widget FieldTextHtmlSimple was called in mode=readonly, a traceback was displayed. This is not very common, because most save operations are done in mode=edit, but it can happen in readonly mode: when the user clicks on an action button, then the form view is saved, if necessary. To reproduce this bug, just open a form view for res.users, and click on the Change Password button.
This commit is contained in:
@@ -39,7 +39,7 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend({
|
||||
*/
|
||||
commitChanges: function () {
|
||||
// switch to WYSIWYG mode if currently in code mode to get all changes
|
||||
if (config.debug) {
|
||||
if (config.debug && this.mode === 'edit') {
|
||||
var layoutInfo = this.$textarea.data('layoutInfo');
|
||||
$.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo, false);
|
||||
}
|
||||
|
||||
@@ -121,4 +121,31 @@ QUnit.test('field html_frame widget', function (assert) {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('field htmlsimple does not crash when commitChanges is called in mode=readonly', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var form = testUtils.createView({
|
||||
View: FormView,
|
||||
model: 'mass.mailing',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<header>' +
|
||||
'<button name="some_method" class="s" string="Do it" type="object"/>' +
|
||||
'</header>' +
|
||||
'<sheet>' +
|
||||
'<field name="body"/>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
res_id: 1,
|
||||
intercepts: {
|
||||
execute_action: function () {
|
||||
assert.step('execute_action');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
form.$('button:contains(Do it)').click();
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user