[IMP] web_editor, *: remove assets from documents
* web "Document" tab in "Select a media" Dialog was displaying all the assets files. Now all files containing "assets_" are excluded from the "Document" tab. This is similar to the regenerateAssets function in debug_manager that deletes assets based on this criteria. For consistency the Assets Domain is now a utils.js function Part of https://github.com/odoo/odoo/pull/33195 task-1945874
This commit is contained in:
@@ -771,7 +771,18 @@ var utils = {
|
||||
}
|
||||
return curr;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the domain targeting assets files.
|
||||
*
|
||||
* @returns {Array} Domain of assets files
|
||||
*/
|
||||
assetsDomain: function () {
|
||||
return [
|
||||
'&',
|
||||
['res_model', '=', 'ir.ui.view'],
|
||||
['name', 'like', 'assets_']
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
return utils;
|
||||
|
||||
@@ -88,10 +88,7 @@ var DebugManager = Widget.extend({
|
||||
*/
|
||||
regenerateAssets: function () {
|
||||
var self = this;
|
||||
var domain = [
|
||||
['res_model', '=', 'ir.ui.view'],
|
||||
['name', 'like', 'assets_']
|
||||
];
|
||||
var domain = utils.assetsDomain();
|
||||
this._rpc({
|
||||
model: 'ir.attachment',
|
||||
method: 'search',
|
||||
|
||||
@@ -821,6 +821,14 @@ var DocumentWidget = FileWidget.extend({
|
||||
this.$addUrlButton.text((isURL && isImage) ? _t("Add as image") : _t("Add document"));
|
||||
this.$urlWarning.toggleClass('d-none', !isURL || !isImage);
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_getAttachmentsDomain: function (needle) {
|
||||
var domain = this._super.apply(this, arguments);
|
||||
// the assets should not be part of the documents
|
||||
return domain.concat('!', utils.assetsDomain());
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user