Missing / wrong indented code during rewrite of binary controller: https://github.com/odoo/odoo/commit/7d85ab1#diff-1407a8ce197a04eefaefa26c127a4418L343-L348 In case you have: <record id="s_cover_default_image" model="theme.ir.attachment"> <field name="key">website.s_cover_default_image</field> <field name="url">/web/image/theme_treehouse.bg_img_15</field> </record> theme_treehouse.bg_img_15 will be not found in /web addons. So we need a 301 redirect too. opw-live How to reproduce: odoo.com/trial > Website > Install theme Clean Drop first snippet > background is 404 closes odoo/odoo#40605 X-original-commit: b8ce93e4eb397e1b7a0e1d408d61d2f283223fb9 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
import odoo.tests
|
|
from odoo.tests.common import HOST, PORT
|
|
|
|
|
|
@odoo.tests.common.tagged('post_install', '-at_install')
|
|
class TestWebsiteAttachment(odoo.tests.HttpCase):
|
|
|
|
def test_01_type_url_301_image(self):
|
|
IMD = self.env['ir.model.data']
|
|
IrAttachment = self.env['ir.attachment']
|
|
|
|
img1 = IrAttachment.create({
|
|
'public': True,
|
|
'name': 's_banner_default_image.jpg',
|
|
'type': 'url',
|
|
'url': '/website/static/src/img/snippets_demo/s_banner.jpg'
|
|
})
|
|
|
|
img2 = IrAttachment.create({
|
|
'public': True,
|
|
'name': 's_banner_default_image.jpg',
|
|
'type': 'url',
|
|
'url': '/web/image/test.an_image_url'
|
|
})
|
|
|
|
IMD.create({
|
|
'name': 'an_image_url',
|
|
'module': 'test',
|
|
'model': img1._name,
|
|
'res_id': img1.id,
|
|
})
|
|
|
|
IMD.create({
|
|
'name': 'an_image_redirect_301',
|
|
'module': 'test',
|
|
'model': img2._name,
|
|
'res_id': img2.id,
|
|
})
|
|
|
|
req = self.url_open('/web/image/test.an_image_url')
|
|
self.assertEqual(req.status_code, 200)
|
|
|
|
base = "http://%s:%s" % (HOST, PORT)
|
|
|
|
req = self.opener.get(base + '/web/image/test.an_image_redirect_301', allow_redirects=False)
|
|
self.assertEqual(req.status_code, 301)
|
|
self.assertEqual(req.headers['Location'], base + '/web/image/test.an_image_url')
|
|
|
|
req = self.opener.get(base + '/web/image/test.an_image_redirect_301', allow_redirects=True)
|
|
self.assertEqual(req.status_code, 200)
|