Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions website_multi_theme/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

===================
Website Multi Theme
===================

Allow the website admin to set a different theme for each website.

Installation
============

To make this module work, you need to either:

* Install any of the officially supported themes:

* theme_bootswatch

* Install any of the unofficially supported themes (at your own risk):

* theme_anelusia
* theme_artists
* theme_avantgarde
* theme_beauty
* theme_bewise
* theme_bistro
* theme_bookstore
* theme_clean
* theme_enark
* theme_graphene
* theme_kea
* theme_loftspace
* theme_mongolia
* theme_nano
* theme_notes
* theme_odoo_experts
* theme_orchid
* theme_treehouse
* theme_vehicle
* theme_yes
* theme_zap

Themes in the above lists will become multiwebsite when installed along this
module. **If they get installed after ``website_multi_theme``, update this
module manually**, or it will not be notified of such change.

Configuration
=============

To configure this module, you need to:

#. Go to *Website Admin > Configuration > Settings* and choose or create
a *Website*.
#. Press *Advanced > Multiwebsite theme > Reload*.
#. In *Advanced > Multiwebsite theme*, pick one of the available themes.

Once you save, any website that has no *Multiwebsite theme* selected will have,
the default plain Bootstrap theme, and those that do have one will get it.

Of course, your Odoo instance must be reachable by all of the provided host
names, or nobody will ever see the effect. But that is most likely configured
through your DNS provider and/or proxy, so it is not a matter of this addon.

If you want to test this behavior, think that ``localhost`` and ``127.0.0.1``
are different host names.

Usage
=====

To use this module, you need to:

#. Follow the configuration steps.
#. Enter any of the websites you modified.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/10.0

Development FAQ
===============

How to develop a multiwebsite-ready theme?
------------------------------------------

Check ``demo/themes.xml``. It includes a demo theme that will serve as a
template for you. This demo theme turns primary buttons green, so you can test
if it is applied or not easily.

How to convert a single-website theme in a multi-website one?
-------------------------------------------------------------

Check ``data/themes_bootswatch.xml``. You must do that. You can consider adding
the support directly in this addon, given it will just do nothing if the
single-website theme addon is not installed (it acts as a soft dependency).

How to get multiwebsite-specific views updated?
-----------------------------------------------

This addon is conservative by default, meaning that in production databases
views will not be updated if they already were created (except for the ones
copied from ``templates/patterns.xml``).

To force your website getting updated views for all views from a base theme
that has changed, you should disable the website multi theme (to make the
engine remove all views) and then re-enable it again (to recreate them from
scratch).

This does not happen in demo or development instances, where views arch is
always updated.

How to test on runbot?
----------------------

* Open ``[[ Website ]] >> Configuration >> Settings``
* Switch *Website* field from ``Website localhost`` to ``Website 0.0.0.0``
* Click *fa-external-link* icon to edit the Website
* At **Website Domain** field copy-paste build domain and add something right after the first dot, for example::

Original domain: 3308093-10-0-28910f.runbot2.odoo-community.org
New domain: 3308093-10-0-28910f.second-website.runbot2.odoo-community.org

* Click ``[Save]`` to save changes at the Website
* Now you can use unchanged build domain for website called ``Website localhost`` and updated domain for website called ``Website 0.0.0.0``

Known issues / Roadmap
======================

* Private themes support is not guaranteed.
* There is no UI to remove websites. Do it through an odoo shell.
* Theme picker should include some kind of thumbnail if possible.
* If you install any of the supported themes after installing this addon, you
will have to press *Reload* in the website config wizard to make it notice
the change.
* If you install any unsupported theme along with this addon, it would possibly
become the base for all those supported, which can easily lead to weird
situations and errors.

Credits
=======

Contributors
------------

* Rafael Blasco <rafael.blasco@tecnativa.com>
* Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* `Ivan Yelizariev <https://it-projects.info/team/yelizariev>`__

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
5 changes: 5 additions & 0 deletions website_multi_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import models
from . import wizards
39 changes: 39 additions & 0 deletions website_multi_theme/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

{
"name": "Website Multi Theme",
"summary": "Support different theme per website",
"version": "11.0.1.0.0",
"category": "Website",
"website": "https://www.tecnativa.com",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": [
"website",
],
"data": [
"security/ir.model.access.csv",
"wizards/website_config_settings_view.xml",
"data/themes_bootswatch.xml",
"data/themes_private.xml",
"templates/assets.xml",
"templates/patterns.xml",
],
"demo": [
"demo/pages.xml",
"demo/themes.xml",
"demo/website.xml",
],
"external_dependencies": {
"bin": [
"lessc",
"sass",
"scss",
],
},
}
12 changes: 12 additions & 0 deletions website_multi_theme/data/themes_bootswatch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
<odoo>

<!-- To use this theme, install theme_bootswatch -->
<record model="website.theme" id="bootswatch_multi">
<field name="name">Multiwebsite Bootswatch Theme</field>
<field name="converted_theme_addon">theme_bootswatch</field>
</record>

</odoo>
114 changes: 114 additions & 0 deletions website_multi_theme/data/themes_private.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
<odoo>

<!-- To enable these themes, install their corresponding private addon
from https://www.odoo.com/apps/themes. Support for these themes
is not guaranteed, use at your own risk. -->
<record model="website.theme" id="anelusia_multi">
<field name="name">Multiwebsite Anelusia Theme</field>
<field name="converted_theme_addon">theme_anelusia</field>
</record>

<record model="website.theme" id="artists_multi">
<field name="name">Multiwebsite Artists Theme</field>
<field name="converted_theme_addon">theme_artists</field>
</record>

<record model="website.theme" id="avantgarde_multi">
<field name="name">Multiwebsite Avantgarde Theme</field>
<field name="converted_theme_addon">theme_avantgarde</field>
</record>

<record model="website.theme" id="beauty_multi">
<field name="name">Multiwebsite Beauty Theme</field>
<field name="converted_theme_addon">theme_beauty</field>
</record>

<record model="website.theme" id="bewise_multi">
<field name="name">Multiwebsite Bewise Theme</field>
<field name="converted_theme_addon">theme_bewise</field>
</record>

<record model="website.theme" id="bistro_multi">
<field name="name">Multiwebsite Bistro Theme</field>
<field name="converted_theme_addon">theme_bistro</field>
</record>

<record model="website.theme" id="bookstore_multi">
<field name="name">Multiwebsite Bookstore Theme</field>
<field name="converted_theme_addon">theme_bookstore</field>
</record>

<record model="website.theme" id="clean_multi">
<field name="name">Multiwebsite Clean Theme</field>
<field name="converted_theme_addon">theme_clean</field>
</record>

<record model="website.theme" id="enark_multi">
<field name="name">Multiwebsite Enark Theme</field>
<field name="converted_theme_addon">theme_enark</field>
</record>

<record model="website.theme" id="graphene_multi">
<field name="name">Multiwebsite Graphene Theme</field>
<field name="converted_theme_addon">theme_graphene</field>
</record>

<record model="website.theme" id="kea_multi">
<field name="name">Multiwebsite Kea Theme</field>
<field name="converted_theme_addon">theme_kea</field>
</record>

<record model="website.theme" id="loftspace_multi">
<field name="name">Multiwebsite Loftspace Theme</field>
<field name="converted_theme_addon">theme_loftspace</field>
</record>

<record model="website.theme" id="monglia_multi">
<field name="name">Multiwebsite Monglia Theme</field>
<field name="converted_theme_addon">theme_monglia</field>
</record>

<record model="website.theme" id="nano_multi">
<field name="name">Multiwebsite Nano Theme</field>
<field name="converted_theme_addon">theme_nano</field>
</record>

<record model="website.theme" id="notes_multi">
<field name="name">Multiwebsite Notes Theme</field>
<field name="converted_theme_addon">theme_notes</field>
</record>

<record model="website.theme" id="odoo_experts_multi">
<field name="name">Multiwebsite Odoo_experts Theme</field>
<field name="converted_theme_addon">theme_odoo_experts</field>
</record>

<record model="website.theme" id="orchid_multi">
<field name="name">Multiwebsite Orchid Theme</field>
<field name="converted_theme_addon">theme_orchid</field>
</record>

<record model="website.theme" id="treehouse_multi">
<field name="name">Multiwebsite Treehouse Theme</field>
<field name="converted_theme_addon">theme_treehouse</field>
</record>

<record model="website.theme" id="vehicle_multi">
<field name="name">Multiwebsite Vehicle Theme</field>
<field name="converted_theme_addon">theme_vehicle</field>
</record>

<record model="website.theme" id="yes_multi">
<field name="name">Multiwebsite Yes Theme</field>
<field name="converted_theme_addon">theme_yes</field>
</record>

<record model="website.theme" id="zap_multi">
<field name="name">Multiwebsite Zap Theme</field>
<field name="converted_theme_addon">theme_zap</field>
</record>

</odoo>
52 changes: 52 additions & 0 deletions website_multi_theme/demo/pages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>

<template id="demo_page_view" name="Multi website theme demo page">
<t t-call="website.layout">
<section class="jumbotron s_big_message" style="background-image: url('/web/image/website.s_background_image_01');">
<div class="container">
<div class="row">
<div class="mb32 col-md-offset-1 col-md-8">
<h1>This is a demo page</h1>
<p>You should see the button with a ugly green border if this website has enabled the demo theme.</p>
<a class="btn btn-primary btn-lg" href="#">
Website domain:
<span id="website_domain"
t-esc="website.domain"/>
</a>
</div>
</div>
</div>
</section>
</t>
</template>

<record id="demo_page" model="website.page">
<field name="website_published">True</field>
<field name="url">/website_multi_theme</field>
<field name="view_id" ref="demo_page_view" />
</record>


<record id="menu_demo_page" model="website.menu">
<field name="name">Multi website theme demo page</field>
<field name="url">/website_multi_theme</field>
<field name="parent_id" ref="website.main_menu" />
<field name="sequence" type="int">50</field>
<field name="website_id" ref="website.default_website"/>
<field name="page_id" ref="demo_page" />
</record>


<record id="menu_demo_page2" model="website.menu">
<field name="name">Multi website theme demo page</field>
<field name="url">/website_multi_theme</field>
<field name="parent_id" ref="website.website2_main_menu" />
<field name="sequence" type="int">50</field>
<field name="website_id" ref="website.website2"/>
<field name="page_id" ref="demo_page" />
</record>

</odoo>
Loading