:banner: banners/build_a_theme.jpg ===================== Theme Tutorial ===================== .. rst-class:: lead Odoo celebrates freedom. Freedom for the designer to go further and freedom for the user to customize everything according to their needs. Ready to create your own theme? Great. Here are some things you should know before you begin. This tutorial is a guide to creating an Odoo theme. .. image:: theme_tutorial_assets/img/Intro.jpg .. warning:: This tutorial requires having installed Odoo v8.0 and the Theme Support Engine (website_less) module. https://www.odoo.com/apps/8.0/website_less/ An introduction for web designers ================================= If you are a web designer using Odoo for the first time, you are in the right place. This introduction will outline the basics of Odoo theme creation. .. note:: Odoo’s team has created a framework that’s powerful and easy to use. There’s no need to know special syntaxes to use this set of tools. From common CMS to Odoo ----------------------- .. note:: If you always think and work in the same way, you’ll probably get the same results. If you want something completely new, then try something different. .. Where is my header.php file? This is usually the first question from a web designer used to working with Wordpress or Joomla and coming to Odoo for the first time. .. container:: col-sm-4 .. image:: theme_tutorial_assets/img/cms.jpg .. container:: col-sm-7 Indeed, when using common CMSs, you have to code several files (like header.php, page.php, post.php, etc.) in order to create a basic structure for your website. With those systems, this base structure acts as a design foundation that you have to update over time to ensure compatibility within your CMS. So, even after you have spent hours coding the files, you have not even started on the design yet. This **does not** apply to creating Odoo themes. .. note:: :class: col-sm-12 We think that theme design should be simple (and powerful). When we created our Website Builder, we decided to start from scratch instead of relying on what already existed. This approach gave us the freedom to focus on the things that are really important for designers: styles, content and the logic behind them. No more struggling with technical stuff. Odoo default theme structure ---------------------------- .. container:: col-sm-8 Odoo comes with a default theme structure. It is a very basic “theme” that provides minimal structure and layout. When you create a new theme, you are actually extending this. Indeed it’s always enabled in your setup and it acts exactly like the CMS’s base structure we mentioned above, except that you don’t have to create or maintain it. It will upgrade automatically within your Odoo installation and, since it is included in the Website Builder module, everything is smoothly integrated by default. As a result, you are totally free to focus on design while this structure does the job of providing integrations and functionality. .. container:: col-sm-4 .. image:: theme_tutorial_assets/img/def_structure.jpg .. container:: col-md-6 **Main features:** * Basic layouts for pages, blog and eCommerce * Website Builder integration * Basic Snippets * Automatic Less/Sass compiling * Automatic Js and CSS minification and combination .. container:: col-md-6 **Main technologies:** * Twitter Bootstrap * jQuery * jQuery UI * underscore.js Thinking "modular" ================== An Odoo theme is not a folder containing HTML or PHP files, it’s a modular framework written in XML. Never worked with XML files before? Don’t worry, after following the tutorial, you’ll be able to create your first theme with only basic knowledge of HTML. Using classical web design workflows, you usually code the layout of the entire page. The result of this is a “static” web page. You can update the content, of course, but your client will need you to work on making even basic changes. Creating themes for Odoo is a total change of perspective. Instead of defining the complete layout for a page, you can create blocks (snippets) at let the user choose where to “drag&drop” them, creating the page layout on their own. We call this modular design. Imagine an Odoo theme as a “list” of elements and options that you have to create and style. As a designer, your goal is to style these elements in order to achieve a wonderful result, regardless of where the end user chooses to place them. Let’s take a tour of our “list” elements: .. row .. figure:: theme_tutorial_assets/img/snippet.jpg :figclass: col-sm-6 Snippets (or building-blocks) A piece of HTML code. The user will drag&drop, modify and combine them using our built-in Website Builder interface. You can define sets of options and styles for each snippet. The user will choose from them according to their needs. .. figure:: theme_tutorial_assets/img/page.jpg :figclass: col-sm-6 Pages These are normal web pages, except that they will be editable by the final user and that you can define an empty area that the user can “fill” by dragging snippets into it. .. /row .. raw:: html
.. figure:: theme_tutorial_assets/img/styles.jpg :figclass: col-sm-6 Styles Styles are defined using standard CSS files (or Less/Sass). You can define a style as **default** or **optional**. The default styles are always active in your theme, the optional styles can be enabled or disabled by the user. .. figure:: theme_tutorial_assets/img/functionalities.jpg :figclass: col-sm-6 Functionalities Thanks to Odoo’s modularity, everything can be personalized even more. This means there are endless possibilities for your creativity. Adding functionalities is easy and it’s simple to provide the end user with customizable options. .. /row Odoo's XML files, an overview ----------------------------- Any Odoo XML file starts with encoding specifications. After that, you have to write your code inside a ```` tag, placed into an ```` tag. .. code-block:: xml [XML]   ## YOUR CODE HERE   Almost every element and option that you create has to be placed inside a ``