diff options
| author | Jeremy Kersten <jke@odoo.com> | 2019-06-13 09:26:39 +0000 |
|---|---|---|
| committer | Jeremy Kersten <jke@odoo.com> | 2019-06-13 09:26:54 +0000 |
| commit | f727cd2645deeb43bcfe1e5643dd3477a6076ab9 (patch) | |
| tree | eb430a54ce1cbfaad60cb7f526507e040e19059a /addons/website/tests | |
| parent | 22437e331a60c81a80d619c075a9d516e980c078 (diff) | |
[IMP] base, model, website[*]: add get_base_url helper
Before this commit, when we want to make an external url, we need to know
if the record is related to a specific website or not, and choose base_url
or website domain.
Now each model have a fonction get_base_url (public to be callable from email
template, ...) and website override this function to add the website domain if
the record is website specific.
closes odoo/odoo#34089
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website/tests')
| -rw-r--r-- | addons/website/tests/__init__.py | 1 | ||||
| -rw-r--r-- | addons/website/tests/test_base_url.py | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/addons/website/tests/__init__.py b/addons/website/tests/__init__.py index f1f4a459cee..bfc1659e9b0 100644 --- a/addons/website/tests/__init__.py +++ b/addons/website/tests/__init__.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import test_converter +from . import test_base_url from . import test_get_current_website from . import test_qweb from . import test_crawl diff --git a/addons/website/tests/test_base_url.py b/addons/website/tests/test_base_url.py new file mode 100644 index 00000000000..8b98ea4e2d9 --- /dev/null +++ b/addons/website/tests/test_base_url.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import odoo +import odoo.tests + + +@odoo.tests.tagged('-at_install', 'post_install') +class TestBaseUrl(odoo.tests.HttpCase): + def test_base_url(self): + ICP = self.env['ir.config_parameter'] + Website = self.env['website'] + + icp_base_url = ICP.sudo().get_param('web.base.url') + domain ='https://www.domain.jke' + + website = Website.create({'name': 'test base url', 'domain': domain}) + without_website_id = website # a model that don't have website_id as field + with_website_id = self.env['res.partner'].create({'name': 'test base url'}) + + self.assertEqual(without_website_id.get_base_url(), icp_base_url) + + with_website_id.website_id = False + self.assertEqual(with_website_id.get_base_url(), icp_base_url) + + with_website_id.website_id = website + self.assertEqual(with_website_id.get_base_url(), domain) + + website.domain = False + self.assertEqual(with_website_id.get_base_url(), icp_base_url) + + + |
