Website support

Odoo bundles a module dedicated to building websites.

So far we've used controllers fairly directly, but Odoo 8 added deeper integration and a few other services (e.g. default styling, theming) via thewebsitemodule.

  1. first, add websiteas a dependency to academy
  2. then add the website=Trueflag on the controller, this sets up a few new variables on the request object and allows using the website layout in our template
  3. use the website layout in the template

academy/\_manifest__.py_

    'version': '0.1',

    # any module necessary for this one to work correctly
    'depends': ['website'],

    # always loaded
    'data': [

academy/controllers.py

from odoo import http

class Academy(http.Controller):
    @http.route('/academy/academy/', auth='public', website=True)
    def index(self, **kw):
        Teachers = http.request.env['academy.teachers']
        return http.request.render('academy.index', {

academy/templates.xml

<odoo>
    <data>
        <template id="index">
            <t t-call="website.layout">
                <t t-set="title">Academy</t>
                <div class="oe_structure">
                    <div class="container">
                        <t t-foreach="teachers" t-as="teacher">
                            <p><t t-esc="teacher.id"/> <t t-esc="teacher.name"/></p>
                        </t>
                    </div>
                </div>
            </t>
        </template>
        <!-- <template id="object"> -->

After restarting the server while updating the module (in order to update the manifest and template) access

http://localhost:8069/academy/academy/

should yield a nicer looking page with branding and a number of built-in page elements (top-level menu, footer, …)

The website layout also provides support for edition tools: clickSign In(in the top-right), fill the credentials in (admin/adminby default) then clickLog In.

You're now in Odoo "proper": the administrative interface. For now click on theWebsitemenu item (top-left corner.

We're back in the website but as an administrator, with access to advanced edition features provided by the_website_support:

  • a template code editor (Customize ‣ HTML Editor) where you can see and edit all templates used for the current page
  • the Edit button in the top-left switches to "edition mode" where blocks (snippets) and rich text edition are available
  • a number of other features such as mobile preview or SEO

results matching ""

    No results matching ""