How to use CSS and JS resources in a routed page in Odoo?

411 Views Asked by At

I’m using Odoo controller to create a web page and make it public to customer so he doesn’t need to login.

In this page I’m trying to use CSS and JS libraries which exists in files inside the module (static folder).

The problem is that the page can’t reach these resources because it searches for them in the domain of the URL not in the filesystem (ex. http://localhost:8069/mywebpage)

I tried to inherit the template and the qweb design and inject the files but I got the same problem.

<template inherit_id="..."> <xpath expr="." position="inside"> <link rel="stylesheet" href="...">

The only solution I have found is copy/paste the source code of the JS libraries and CSS inside the template which is not a practical solution.

How can I make the routed page access the CSS and JS resources inside Odoo module?

1

There are 1 best solutions below

2
On

Just put the module path of your assets resources, like:

<link rel="stylesheet" href="/your_custom_module/static/src/css/file.css">

And be sure the file will be there, the same for js script definition.

Also you should include in your posts the exact info and value that you are using, not .... It doesn't help you into get a response using ..., it just makes things difficult.