Old heuristic is not more True: Force to check method to POST. Odoo uses methods : ['POST'] and ['GET', 'POST'] We have some controller that only allow 'GET' method, so we need to check GET also when we try to know if an url is multilang or not. This commit fix case where a controller '/test' only allow GET and you were in another language that the default, in this case, the rendered url in qweb was /get instead of /<lang>/get. Closes #37223 closes odoo/odoo#40519 X-original-commit: c7650106f8588083be12812600a6c94ba703fd6f Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
import odoo.tests
|
|
import lxml
|
|
|
|
|
|
@odoo.tests.common.tagged('post_install', '-at_install')
|
|
class TestIsMultiLang(odoo.tests.HttpCase):
|
|
|
|
def test_01_is_multilang_url(self):
|
|
website = self.env['website'].search([], limit=1)
|
|
fr = self.env.ref('base.lang_fr').sudo()
|
|
en = self.env.ref('base.lang_en').sudo()
|
|
|
|
fr.active = True
|
|
fr_prefix = "/" + fr.iso_code
|
|
|
|
website.default_lang_id = en
|
|
website.language_ids = en + fr
|
|
|
|
for data in [None, {'post': True}]: # GET / POST
|
|
body = lxml.html.fromstring(self.url_open('/fr/multi_url', data=data).content)
|
|
|
|
self.assertEqual(fr_prefix + '/get', body.find('./a[@id="get"]').get('href'))
|
|
self.assertEqual(fr_prefix + '/post', body.find('./form[@id="post"]').get('action'))
|
|
self.assertEqual(fr_prefix + '/get_post', body.find('./a[@id="get_post"]').get('href'))
|
|
self.assertEqual('/get_post_nomultilang', body.find('./a[@id="get_post_nomultilang"]').get('href'))
|