Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
13132 Переглядів

Hi everybody,

I've a fresh installation of Odoo v12,

I created a custom module that contains only init, manifest files and a views folder.

Inside views folder there is 2 xml files : layout.xml and homepage.xml.

The layout.xml file contain header and footer of my website app.

The homepafe.xml file contain custom content to show in the home page.

The probleme is : the layout is working fine, but the homepage template is not! It does not appear in the frontend of my website. Instead I see only the default "Welcome to your Homepage. Let's start designing." of the native website module.

Website module is installed.

Homepage.xml:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <template id="myproject_homepage" name="Myproject Home" inherit_id="website.homepage">
        <xpath expr="//div[@id='wrap']" position="replace">
            <div id="wrap" class="oe_structure">
                <h1>Home test</h1>
            </div>
        </xpath>
    </template>
</odoo>

Layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <template id="myproject_layout" name="Main layout" inherit_id="portal.frontend_layout">
        <xpath expr="//header" position="replace">
            <!-- Header -->
            <header class="header">
                Header
            </header>
        </xpath>
        <xpath expr="//main" position="replace">
            <main>
                <!-- Content -->
                <t t-raw="0" />
                
            </main>
        </xpath>
        <xpath expr="//footer" position="replace">
            <!-- FOOTER -->
            <footer class="footer">
                Footer
            </footer>

        </xpath>
    </template>

__manifest__.py:
 
# -*- coding: utf-8 -*-
{
    'name':'My Theme',
    'description': 'A description for your theme.',
    'version':'1.0',
    'author':'Aissa BOUGUERN',

    'data': [
        'views/layout.xml',
        'views/homepage.xml'
        

    ],
    'category': 'Theme/Creative',
    'depends': ['website'],
}

Thank you!
Аватар
Відмінити

Did you get any solution to this?

Найкраща відповідь

Hi, You can check this: 

https://youtu.be/zqFuvqnC3zs

Hope it helps

Аватар
Відмінити
Найкраща відповідь

Hi,
We found any wrong in your code. But if you face the same problem again then replace your code by the following code in your homepage.XML view file. Then upgrade your module.

<template id="homepage_test" name="HomePage" inherit_id="website.homepage">
       <xpath expr="//div[@id='wrap']" position="replace">
        <div id="wrap" class="oe_structure">
                       <h1>Test Home Page</h1>
        </div>
       </xpath>
   </template>

Regards

Аватар
Відмінити
Найкраща відповідь

In odoo you need to use <t t-call=website.layout> to customize the page....this because odoo use header and footer like crosspage but the main change based on url/context.So to modify the layout page call website.layout and add your data there.



<template id="s_index">
<t t-call="website.layout">
<t t-set="title"><t t-esc="website.name"/></t>
  <div class="oe_structure">
    Add your html here                          
  </div>
</t>
</template>
Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
3
лип. 20
14381
1
січ. 24
1254
1
вер. 21
6647
Theme Вирішено
2
лист. 24
1247
0
жовт. 24
885