Add external javascript library to odoo 12

1.8k views Asked by At

Hello i'm new to odoo and i'm using version 12, i want to add an external javascript library which is loading.io https://loading.io/progress/.

I don't know how to add it because i saw that it is not possible to use a cdn.

Any help or hint will be appreciated and thanks in advance.

1

There are 1 answers

0
Daniel Reis On BEST ANSWER

The add a Javascript or CSS asset to Odoo, extend the appropriate assets template.

This might be:

  • web.assets_frontend for frontend web pages.
  • web.assets_backend for backend webclient pages.
  • web.assets_common for both backend and frontend.

The asset files, if bundled should be inside your module, in a static/lib/css and static/lib/js subdirectories.

For example:

<odoo>
  <template id="mymodule_web_assets" name="My Web Assets"
            inherit_id="web.assets_frontend">
     <xpath expr="." position="inside">

       <link rel="stylesheet" type="text/css"
             href="/<mymodule>/static/lib/css/loading-bar.css"/>
       <script type="text/javascript"
               src="/<mymodule>/static/lib/js/loading-bar.js"></script>

    </xpath>
  </template>
</odoo>