Odoo Help


How to add snippet with CSS and JS?

on 11/13/14, 10:41 PM 3,068 views

i have created a snippet but the css and js are not being called. 

this is in my snippet.xml

<section class="oe_snippet_body fancybox">
                        <div class="col-md-3">
                            <div class="post-thumbnail element">
                                <img src="/website_fancybox/static/img/Moon.jpg"/> 
                                <a data-fancybox-group="gallery" href="/website_fancybox/static/img/Moon.jpg"
                                class="element-lightbox fancybox">
                                <i class="fa fa-search-plus"></i></a>

and i tried to call the css and js using assets.xml


        <template id="javascripts_head" inherit_id="website.layout">
            <xpath expr="//head" position="inside">
              <link href="/website_fancybox/static/css/bootstrap.min.css" rel="stylesheet" type="text/less"/>
              <link href="/website_fancybox/static/css/style.css" rel="stylesheet" type="text/less"/>
              <link href="/website_fancybox/static/css/jquery.fancybox.css" rel="stylesheet" type="text/less"/>
              <script type="text/javascript" src="/website_fancybox/static/src/js/fboxscript.js"></script>
              <script type="text/javascript" src="/website_fancybox/static/src/js/jquery.fancybox.js"></script>
              <script type="text/javascript" src="/website_fancybox/static/src/js/jquery-1.10.1.min.js"></script>


how do i make this work. i wanted the image to show in col-md-3 size not its original size. also the js would bring up modal box. 

Haojun Zou
On 6/29/15, 6:26 AM

You need a template that inherit "website.assets_editor", something like that:

<template id="custom_css_and_js" inherit_id="website.assets_editor" name="Custom CSS and JS">

    <xpath expr="//link[last()]" position="after">

        <!-- your custom css goes here -->


    <xpath expr="//script[last()]" position="after">

        <!-- your custom javascript goes here -->



About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/13/14, 10:41 PM
Seen: 3068 times
Last updated: 6/29/15, 6:26 AM