diff --git a/addons/website/models/__init__.py b/addons/website/models/__init__.py index efeda5560b7..ac493be6cd8 100644 --- a/addons/website/models/__init__.py +++ b/addons/website/models/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import assetsbundle from . import ir_actions from . import ir_attachment from . import ir_http diff --git a/addons/website/models/assetsbundle.py b/addons/website/models/assetsbundle.py new file mode 100644 index 00000000000..d4e4760acc9 --- /dev/null +++ b/addons/website/models/assetsbundle.py @@ -0,0 +1,11 @@ + +from odoo.addons.base.models.assetsbundle import WebAsset + +_old_get_stat_attachment_domain = WebAsset._get_stat_attachment_domain + +def _new_get_stat_attachment_domain(self): + domain = _old_get_stat_attachment_domain(self) + website = self.bundle.env['website'].get_current_website() + return domain + website.website_domain() + +WebAsset._get_stat_attachment_domain = _new_get_stat_attachment_domain diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index 7ca7563159b..3f284fdffeb 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -149,6 +149,12 @@ class Http(models.AbstractModel): domain = [('url_from', '=', req_page)] + request.website.website_domain() return request.env['website.redirect'].search(domain, limit=1) + @classmethod + def _get_serve_attachment_domain(cls): + domain = super(Http, cls)._get_serve_attachment_domain() + website = request.env['website'].get_current_website() + return domain + website.website_domain() + @classmethod def _serve_fallback(cls, exception): # serve attachment before diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index 8f5400347a8..bfeaf3a9636 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -615,12 +615,15 @@ class WebAsset(object): try: # Test url against ir.attachments fields = ['__last_update', 'datas', 'mimetype'] - domain = [('type', '=', 'binary'), ('url', '=', self.url)] + domain = self._get_stat_attachment_domain() attach = self.bundle.env['ir.attachment'].sudo().search_read(domain, fields) self._ir_attach = attach[0] except Exception: raise AssetNotFound("Could not find %s" % self.name) + def _get_stat_attachment_domain(self): + return [('type', '=', 'binary'), ('url', '=', self.url)] + # depreciated and will remove after v11 def to_html(self): tagName, attributes, content = self.to_node() diff --git a/odoo/addons/base/models/ir_http.py b/odoo/addons/base/models/ir_http.py index 84b29147f40..fa27d92e458 100644 --- a/odoo/addons/base/models/ir_http.py +++ b/odoo/addons/base/models/ir_http.py @@ -126,7 +126,7 @@ class IrHttp(models.AbstractModel): @classmethod def _serve_attachment(cls): env = api.Environment(request.cr, SUPERUSER_ID, request.context) - domain = [('type', '=', 'binary'), ('url', '=', request.httprequest.path)] + domain = cls._get_serve_attachment_domain() fields = ['__last_update', 'datas', 'name', 'mimetype', 'checksum'] attach = env['ir.attachment'].search_read(domain, fields) if attach: @@ -152,6 +152,10 @@ class IrHttp(models.AbstractModel): response.data = base64.b64decode(datas) return response + @classmethod + def _get_serve_attachment_domain(cls): + return [('type', '=', 'binary'), ('url', '=', request.httprequest.path)] + @classmethod def _serve_fallback(cls, exception): # serve attachment