summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2020-12-22 11:17:56 +0000
committerqsm-odoo <qsm@odoo.com>2020-12-24 13:21:20 +0000
commitdca6d7382e5d84997648952d442ad77df5d6ee82 (patch)
tree08910333d0eae0233f9f41c2372510cd33af9cb3 /addons/web_editor/static/src/js
parentd31a86cead03623c375f4162324a6d1872cad6a3 (diff)
[FIX] web_editor: stop suggesting shapes for model-related images
Those kind of images use a specific route (/web_editor/shape/...) to be fetched. While waiting for a more complete solution to maybe handle them for model-related images, this commit only allows their use for images in views and HTML fields. closes odoo/odoo#63682 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.summernote.js6
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/widgets/media.js6
2 files changed, 10 insertions, 2 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.summernote.js b/addons/web_editor/static/src/js/editor/rte.summernote.js
index 7b77404634f..6ea8f1b984b 100644
--- a/addons/web_editor/static/src/js/editor/rte.summernote.js
+++ b/addons/web_editor/static/src/js/editor/rte.summernote.js
@@ -1210,11 +1210,15 @@ var SummernoteManager = Class.extend(mixins.EventDispatcherMixin, ServicesMixin,
}
data.__alreadyDone = true;
+ const model = data.$editable.data('oe-model');
+ const field = data.$editable.data('oe-field');
+ const type = data.$editable.data('oe-type');
var mediaDialog = new weWidgets.MediaDialog(this,
_.extend({
- res_model: data.$editable.data('oe-model'),
+ res_model: model,
res_id: data.$editable.data('oe-id'),
domain: data.$editable.data('oe-media-domain'),
+ useMediaLibrary: field && (model === 'ir.ui.view' && field === 'arch' || type === 'html'),
}, data.options),
data.media
);
diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js
index d074e5d9c38..ed33b79240a 100644
--- a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js
+++ b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js
@@ -143,6 +143,7 @@ var FileWidget = SearchableMediaWidget.extend({
this.options = _.extend({
mediaWidth: media && media.parentElement && $(media.parentElement).width(),
+ useMediaLibrary: true,
}, options || {});
this.attachments = [];
@@ -301,6 +302,9 @@ var FileWidget = SearchableMediaWidget.extend({
if (needle && needle.length) {
domain.push(['name', 'ilike', needle]);
}
+ if (!this.options.useMediaLibrary) {
+ domain.push('!', ['url', '=ilike', '/web_editor/shape/%']);
+ }
domain.push('!', ['name', '=like', '%.crop']);
domain.push('|', ['type', '=', 'binary'], '!', ['url', '=like', '/%/static/%']);
return domain;
@@ -758,7 +762,7 @@ var ImageWidget = FileWidget.extend({
attachment.thumbnail_src = newURL.pathname + newURL.search;
}
});
- if (this.needle) {
+ if (this.needle && this.options.useMediaLibrary) {
try {
const response = await this._rpc({
route: '/web_editor/media_library_search',