Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4304 Zobrazení

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...

Avatar
Zrušit
Autor

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

Related Posts Odpovědi Zobrazení Aktivita
1
kvě 20
3887
2
úno 20
5681
0
pro 19
3909
1
čvn 24
3302
1
bře 22
1710