[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: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user