Search code examples
odooodoo-17

How to add button to customer portal: Odoo17


I want to add a button to the customer portal:

Screenshot of customer portal

I added this view

<template id="portal_my_home" name="Show Blogposts" customize_show="True" inherit_id="portal.portal_my_home" priority="20">

    <xpath expr="//div[hasclass('o_portal_docs')]" position="before">
        <t t-set="portal_client_category_enable" t-value="True"/>
    </xpath>

    <div id="portal_client_category" position="inside">
        <t t-call="portal.portal_docs_entry">
            <t t-set="title">Test</t>
            <t t-set="url" t-value="'/my/controller'"/>
            <t t-set="text">Test Button</t>
        </t>
    </div>

</template>

in my view. As always: the view is added to the manifest data part, I reinstalled the module, I can see it from Developer settings Technial > views > and I can see it's correctly inheriting when I visit the portal.portal_my_home and I see that mymodule.portal_my_home is listed as an inheriting view.

I've tried multiple variations of this, yet I can not get the button to show up. Is there something I'm missing?

I copied the code from odoo's hr module for example (as suggested in this post Odoo17 Add Portal Menu) but still no results.

Help is greatly appreciated!


Solution

  • It is probably rendering properly but it is hidden with "d-none" class

    Check the portal_docs_entry xml template located in portal/views/portal_templates.xml. This is the template you use t-call on

    <div t-att-class="'o_portal_index_card ' +  ('' if config_card else 'd-none ') + ('col-12 order-0' if show_count else 'col-md-6 order-2')">
    

    When the config_card variable is not set it will hide de div with "d-none". Including that variable should solve your issue...

    <div id="portal_client_category" position="inside">
            <t t-call="portal.portal_docs_entry">
                <t t-set="title">Test</t>
                <t t-set="url" t-value="'/my/controller'"/>
                <t t-set="text">Test Button</t>
                <t t-set="config_card" t-value="True"/>
            </t>
        </div>