[IMP] web, web_editor: exclude assets from documents

Currently only the `*.assets_*` CSS and JS files are considered as
assets. Because of this some assets from `web_studio`, `pos` and
`document_spreadsheet` become available for selection as documents.

This commit replaces the existing blacklist by a check on whether the
URL matches `/web/assets/*`.

Steps to reproduce:
- Install website, web_studio and pos.
- Drop a Text - Image block in the home page.
- Replace the Image.
- Go to the Documents tab.
=> Some JS/CSS/map assets were available for selection.

task-2799866

closes odoo/odoo#89151

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Benoit Socias
2022-05-31 19:16:59 +02:00
parent 87d33596d1
commit 76eb6e6c74
2 changed files with 3 additions and 20 deletions
@@ -1129,24 +1129,6 @@ var utils = Object.assign({
}
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\_%.css'],
['name', '=like', '%.assets\_%.js'],
['name', '=like', '%.report_assets\_%.css'],
['name', '=like', '%.assets\_%.map'],
];
},
}, cookieUtils);
return utils;
@@ -1069,8 +1069,9 @@ var DocumentWidget = FileWidget.extend({
*/
_getAttachmentsDomain: function (needle) {
var domain = this._super.apply(this, arguments);
// the assets should not be part of the documents
return domain.concat('!', utils.assetsDomain());
// The assets should not be part of the documents.
// All assets begin with '/web/assets/', see _get_asset_template_url().
return ['&', '|', ['url', '=', null], '!', ['url', '=like', '/web/assets/%']].concat(domain);
},
});