Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link menu in Odoo to a computed URL

Tags:

python

xml

odoo

I need to link a menu item in Odoo to an external link, but this external link is a string stored in model and it is different for every user. I'm not sure how to code this inside the eval attribute of field name url. Or is this possible?

<openerp>
   <data>
        <record id="open_retainer" model="ir.actions.act_url">
            <field name="name">Pay Retainer</field>
            <field name="type">ir.actions.act_url</field>
            <field name="target">new</field>
            <field name="url" eval="'some_url' if True else ''"/>
        </record>

        <menuitem
                name="Pay Retainer"
                id="menu_pay_retainer"
                groups="base.group_portal"
                action="open_retainer"
                parent="portal.portal_orders"/>

    </data>
</openerp>
like image 441
macdelacruz Avatar asked Dec 22 '25 13:12

macdelacruz


1 Answers

Instead of having as menu, you can try by clicking a button in the user screen and redirect to the specific url.

You can try following:

return { 'type': 'ir.actions.act_url', 'url': your_url, 'nodestroy': True, 'target': 'new' }

where 'your_url' is the url string stored for each user.

like image 105
Hardik Patadia Avatar answered Dec 24 '25 02:12

Hardik Patadia