Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

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
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
1
Mei 20
3967
2
Feb 20
5706
0
Des 19
3972
1
Jun 24
3332
1
Mar 22
1756