Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Extending CSS and JavaScript for the website


In this recipe, we'll see how to add custom style sheets and JavaScript to the website.

Getting ready

Create an empty module named ch13_r01 and install it in your test database. Make sure this module depends on the website module, as we use some of its functionality.

How to do it...

Override the main website template to inject your code:

  1. Add a file called views/templates.xml and add an empty view override:

    <odoo>
        <template id="assets_frontend" inherit_id="website.assets_frontend">
            <xpath expr="." position="inside">
                <!-- points 2 & 3 go here /-->
            </xpath>
        </template>
    </odoo>
  2. Add a reference to your CSS file:

    <link href="/ch13_r01/static/src/css/ch13_r01.css" rel="stylesheet" type="text/css"/>
  3. Add a reference to your JavaScript file:

    <script src="/ch13_r01/static/src/js/ch13_r01.js" type="text/javascript" />
  4. Add some CSS code to static/src/css/ch13_r01.css.

    body
    {...