从odoo qweb中的按钮触发动作

Trigger action from button in odoo qweb

我正在尝试 运行 来自 stock.picking 视图的视图,当我使用 menuitem 调用它时没问题,但是当我尝试通过按钮替换 menuitem 时,它没有被触发。

在我的.xml

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

但是那个是错误的。例如,我不想从我的模型中调用 myMethod,但它需要有 name=""。因此,当我单击我的按钮时,它会调用该方法,但我没有像在 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>

那么有没有办法只触发动作而不使用模型方法,就像在 menuitem 中一样?

使用计算函数而不是使用操作。 计算 =“my_action_name”