How to do it...

Override the main website template to inject your code, as follows:

  1. Add a file called views/templates.xml and add an empty view override, as follows (don't forget to list the file in __manifest__.py):
<odoo> 
    <template id="assets_frontend" 
inherit_id="web.assets_frontend"> <xpath expr="." position="inside"> <!-- points 2 & 3 go here /--> </xpath> </template> </odoo>
  1. Add the reference of the CSS and SCSS file, as follows:
<link href="/my_library/static/src/css/my_library.css" rel="stylesheet" type="text/css"/>
<link href="/my_library/static/src/scss/my_library.scss" rel="stylesheet" type="text/scss"/>
  1. Add a reference to your JavaScript file, as follows:
<script src="/my_library/static/src/js/my_library.js" type="text/JavaScript" />
  1. Add some CSS code to static/src/css/my_library.css, as follows:
body main {
background: #b9ced8;
}
  1. Add some SCSS code to static/src/scss/my_library.scss, as follows:
$my-bg-color: #1C2529;
$my-text-color: #D3F4FF;

nav.navbar {
background-color: $my-bg-color !important;
.navbar-nav .nav-link span{
color: darken($my-text-color, 15);
font-weight: 600;
}
}

footer.o_footer {
background-color: $my-bg-color !important;
color: $my-text-color;
}
  1. Add some JavaScript code to static/src/js/my_library.js as follows:
odoo.define('my_library', function (require) {
var core = require('web.core');

alert(core._t('Hello world'));
return {
// if you created functionality to export, add it here
}
});

After updating your module, you should see that Odoo websites have custom colors in the menu, body, and footer, and a somewhat annoying Hello world popup on each page load, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset