Skip to Content
Menu
This question has been flagged
2 Replies
5182 Views

I am trying to create a custom homepage template. In previous versions v11 and before it was done with this code:

    <template id="website.homepage" name="testpage">
        <t t-call="website.layout">
            <div id="wrap">
                <h1>TEST</h1>
            </div>
        </t>
    </template>

But now in v12 it isn't working. The homepage always says 'Design your website'. But it was supposed to show the TEST word on the homepage. What am I doing wrong or what has changed?

Avatar
Discard

Thanks, in your code there is one unfinished line - <t-ref="homepage_custom_template"  , is it <t ref ? or <t-ref >? I don't find any reference of t-ref in odoo.

I wrote the following code -

    <record id="homepage_view" model="ir.ui.view">
        <field name="name">Home Page</field>
        <field name="type">qweb</field>
        <field name="key">website.homepage1</field>
        <field name="mode">primary</field>
        <field name="active">True</field>
        <field name="arch" type="xml">
            <t name="Homepage" t-name="website.homepage1">
                <t t-call="website.layout">
                    <t t-set="pageName" t-value="'homepage'"/>
                    <div id="wrap" class="oe_structure oe_empty">
                        <p>TEST</p>
                    </div>
                </t>
            </t>
        </field>
    </record>

But was unsure about the second record part. But it worked with the website.page model record view.

I made a little error in my example indeed, I've already corrected it so it should be fine now.

Best Answer

Hi Tanzilul,

Since Odoo V12 the multi website has been released and the homepages are now built in another way. You now have a homepage per website (even if you have just one) which means Odoo doesn't know where this links to anymore. I found a workaround for it by setting the is_homepage parameter to true and linking it to a view:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record ref="homepage_custom_template" model="ir.ui.view">
        <field name="name">My custom homepage!</field>
        <field name="type">qweb</field>
        <field name="key">website.homepage.custom</field>
        <field name="arch" type="xml">
            <t t-name="homepage_custom_template">
                <t t-call="website.layout">
                    <p>Some title</p>
                </t>
             </t>
         </field>
     </record>

    <record id="homepage_custom_template_menu" model="website.page">
        <field name="website_published">True</field>
        <field name="url">/custom-home</field>
        <field name="is_homepage">True</field>
        <field name="view_id" ref="homepage_custom_template" />
    </record>
</odoo>


Regards,
Yenthe

Avatar
Discard

Thanks for the tip. You just need to change your attribute in the first record from "ref" to "id".

Related Posts Replies Views Activity
3
Feb 23
20480
0
Sep 24
129
0
Aug 22
1892
0
Dec 20
2622
0
Oct 19
1960