diff --git a/addons/web/controllers/home.py b/addons/web/controllers/home.py index 455e423aec4..c02e1313e4e 100644 --- a/addons/web/controllers/home.py +++ b/addons/web/controllers/home.py @@ -154,3 +154,7 @@ class Home(http.Controller): headers = [('Content-Type', 'application/json'), ('Cache-Control', 'no-store')] return request.make_response(data, headers) + + @http.route(['/robots.txt'], type='http', auth="none") + def robots(self, **kwargs): + return "User-agent: *\nDisallow: /\n" diff --git a/odoo/addons/test_http/tests/test_misc.py b/odoo/addons/test_http/tests/test_misc.py index 2efddb9f8e0..55f470df737 100644 --- a/odoo/addons/test_http/tests/test_misc.py +++ b/odoo/addons/test_http/tests/test_misc.py @@ -136,6 +136,9 @@ class TestHttpMisc(TestHttpBase): self.assertEqual(res.status_code, 200) self.assertEqual(res.text, file.getvalue()) + def test_misc7_robotstxt(self): + self.nodb_url_open('/robots.txt').raise_for_status() + @tagged('post_install', '-at_install') class TestHttpCors(TestHttpBase): def test_cors0_http_default(self):