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

Offering snippets to the user


The website designer offers building blocks in website edit mode which can be dragged on the page. This recipe discusses how to offer your own blocks, called snippets, internally.

Getting ready

As we make use of the library.book model, get chapter 4's code for my_module. For convenience, this recipe's code contains a copy of it.

How to do it...

A snippet is actually just a QWeb view that gets injected in the Insert blocks bar, which is defined by a QWeb view itself:

  1. Add a file called views/snippets.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <odoo>
        <template id="book_snippet" inherit_id="website.snippets">
            <!-- points 2, 3 go here /-->
        </template>
    </odoo>
  2. Add a view for your snippet:

    <xpath expr="//div[@id='snippet_feature']/div[@class='o_panel_body']" position="inside">
        <div>
            <div class="oe_snippet_thumbnail">
                <div style="background: white;box-shadow:none" class="oe_snippet_thumbnail_img...