Search code examples
pythondjangoxmlodooqweb

Trigger action from button in odoo qweb


I'm trying to run a view from stock.picking view and it's ok when I call it using menuitem, but when i'm trying to replace menuitem by button, it's not triggered.

In my .xml

<menuitem name="My Element"  id="menu_elem" action="my_action_name"/> this was working well.

But that one is wrong. For example,I don't want to call the myMethod from my model,but it's required to have name="". So when I click on my button, it calls the method and I hadn't my action triggered like in menuitem

<record id="myId1" model="ir.ui.view">
    <field name="name">stock.picking.form.inherit</field>
    <field name="model">stock.picking</field>
    <field name="inherit_id" ref="stock.view_picking_form"/>
    <field name="arch" type="xml">
    <field name="state" position="before">
        <button name="myMethod"  string="My Element" action="my_action_name" type="object" class="oe_highlight"/>
    </field>
    </field>
</record>

So is there a way to have only triggered action without the use of model method, like in menuitem?


Solution

  • Use compute function instead of using action. compute = "my_action_name"