Files
odoo_source/addons/website/tests/test_base_url.py
T
Jeremy Kersten f727cd2645 [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>
2019-06-13 09:26:54 +00:00

34 lines
1.1 KiB
Python

# -*- 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)