Skip to content
Snippets Groups Projects
Commit f217aa52 authored by mgh-odoo's avatar mgh-odoo Committed by Gorash
Browse files

[FIX]web_editor: Fixed traceback due to 'field_html' widget while saving record


Previously, when user edited record having 'field_html' widget and
tried to save the record immediately, a traceback was faced sometimes
because content was not loaded yet. This commit fixes the issue
by calling super method if the content is not loaded yet properly.

Task: #1932687
Closes: #30833

closes odoo/odoo#31581

Signed-off-by: default avatarVincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
parent 3393dd00
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,9 @@ var MassMailingFieldHtml = FieldHtml.extend({
*/
commitChanges: function () {
var self = this;
if (!this.wysiwyg || !this.isRendered) {
return this._super();
}
var fieldName = this.nodeOptions['inline-field'];
if (this.$content.find('.o_basic_theme').length) {
......
......@@ -39,6 +39,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
* @override
*/
willStart: function () {
this.isRendered = false;
this._onUpdateIframeId = 'onLoad_' + _.uniqueId('FieldHtml');
var defAsset = null;
if (this.nodeOptions.cssReadonly) {
......@@ -91,7 +92,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
*/
commitChanges: function () {
var self = this;
if (!this.wysiwyg) {
if (!this.wysiwyg || !this.isRendered) {
return this._super();
}
var _super = this._super.bind(this);
......@@ -164,6 +165,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
return this.wysiwyg.attachTo(this.$target).then(function () {
self.$content = self.wysiwyg.$editor;
self._onLoadWysiwyg();
self.isRendered = true;
});
},
/**
......
......@@ -517,6 +517,27 @@ QUnit.test('rendering with iframe for edit mode', function (assert) {
});
});
QUnit.test('save immediately before iframe is rendered in edit mode', function (assert) {
var done = assert.async();
assert.expect(1);
testUtils.createAsyncView({
View: FormView,
model: 'note.note',
data: this.data,
arch: '<form>' +
'<field name="body" widget="html" style="height: 100px" options="{\'cssEdit\': \'template.assets\'}"/>' +
'</form>',
res_id: 1,
}).then(function (form) {
testUtils.form.clickEdit(form);
testUtils.form.clickSave(form);
assert.ok(true, "No traceback encountered. The wysiwyg was cut while not loaded.");
form.destroy();
done();
});
});
QUnit.test('use colorpicker and save', function (assert) {
var done = assert.async();
assert.expect(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment