This question has been flagged
1 Reply
12480 Views

I have created a module named test_module with the following structure:

 

  • __init__.py
  • __openerp__.py
  • Views:
      template.xml
  • static
    -- src
         -- js
               -- test.js
  • controllers
      -- main.py
  • data
       -- data.xml
     

And in the template.xml I have specified the JS file as follows in a template

    <template id="test_template">
                <script type="text/javascript" language="JavaScript" src="/gastro_website/static/src/js/gastro_registration.js"/>

               <t t-call="website.layout">

                  -----------------------------

                 -------------------------------

               </t>

    </template>

 and the test.js file is

openerp.test_module = function (instance, local) {

     console.log('qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq');

};

But on loading the page for the template shows in console of the browser:

    Uncaught ReferenceError: openerp is not defined

which is from the test.js file

How to fix this?

 

Avatar
Discard

were you able to solve this problem?

Best Answer

You should add the script by inheriting website.assets_frontend


<template id="assets_frontend" inherit_id="website.assets_frontend" name="My scripts">
<xpath expr="." position="inside">
<script type="text/javascript" src="..."></script>
</xpath>
</template>

Avatar
Discard
Author

I have added the script by inheriting website.assets_frontend, but it didn't resolve the problem.

I think it should be website.assets_editor and not frontend