콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

I'm trying to load JavaScript on my custom page that I've created by using a new route. The route and template is working just fine, but the JS not.

My new route:

class new_route(http.Controller): 
     @http.route("/iframe", type='http', auth="user")
​     def test(self, **kwargs):
      data = [{'login': kwargs.get("login",False)}]    ​            ​               ​            ​

      return http.request.render('my_module.my_template', {'data': data})

My XML template:

<template id="my_template">
 <script>
 console.log("hahahah")
 </script> 

 <t t-foreach="data" t-as="o">
    <p><t t-esc='o.get("login")'/></p>      

</t> 
 </template>

<template id="my_js_test"
name="my js test"
inherit_id="my_template">        
<xpath expr="." position="inside">
 <script type="text/javascript" src="/my_module/static/src/js/my_js_file.js"/>
 </xpath>
 </template> ​  

My JavaScript File:

console.log("BLABLABLA")

My Manifest:

{    'name' : "test_new_template",
 'version' : "13.0",
 'description' : 'TEST',
 'depends': ['base'],
 'data': ['views/my_templates.xml'], 
'js': ['static/src/js/my_js_file.js' ],
 'installable' : True,}   ​            ​             ​            ​     ​            ​         ​            ​     ​            ​         ​            ​     ​            ​         ​            ​     ​            ​             ​            ​     ​            ​         ​            ​     ​            ​     ​            ​     ​            ​         ​            ​     ​            ​             ​            ​     ​            ​         ​            ​  

The problem is that the template is being rendered and getting the information through data with success, but none of those console.log is working, and it was working the same way on ODOO12.

Anyone knows why? I've tried to change the file name, the position, add and remove from monifest, neither way the JS is working and ODOO dont give me any lead...

아바타
취소
작성자

I just changed the route name and now it is working, I simply can't understand ODOO sometimes...

관련 게시물 답글 화면 활동
1
5월 20
4134
2
2월 20
5831
0
12월 19
4097
1
6월 24
3398
1
3월 22
1861