在 Odoo 中创建另一个操作菜单项 [英] Create another action menuitem in Odoo

查看:51
本文介绍了在 Odoo 中创建另一个操作菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展自定义模块视图中定义的操作的功能,为它添加一个新的菜单项.我不确定这样做的代码是如何定义的.

I'm trying to extend the funcionallity of the actions defined in a custom module view adding a new menuitem for it. I'm not sure how is defined the code for doing it.

使用的模型是:education.group

The model used is: education.group

定义的模块是:教育.

<record id="education_group_mailing_action" model="ir.actions.server">
    <field name="name">Generate group lists</field>
    <field name="type">ir.actions.server</field>
    <field name="model_id" ref="model_education_group"/>
    <field name="binding_model_id" ref="model_education_group"/>
    <field name="state">code</field>
    <field name="code">action = records.generate_lists()</field>
</record>

<record id="education_group_mailing_action2" model="ir.default">
        <field name="model_id" ref="model_education_group" />
        <field name="field_id" eval="1" />
        <field name="json_value">False</field>
        <field name="name">Generate group lsts</field>
        <field name="key2">client_action_multi</field>
        <field name="key">action</field>
        <field name="model">education.group</field>
        <field name="value" eval="'ir.actions.server,' + str(ref('education_group_mailing_action'))" />
    </record>

class EducationGroup(models.Model):
    _inherit='education.group'

   def generate_lists(self):
        print("HELLO!")

有人知道怎么做吗?感谢阅读!

Anyone knows how to to it? Thanks for reading!

推荐答案

如果您使用的是 Odoo12.0,那么您必须这样做.

If you are using Odoo12.0 then you have to do like this.

    <record id="new_action1" model="ir.actions.server">
        <field name="name">New Action</field>
        <field name="model_id" ref="model_product_template" />
        <field name="binding_model_id" ref="model_product_template" />
        <field name="state">code</field>
        <field name="code">records.export_product()</field>
    </record>
    <record id="run_product_new_order_action2" model="ir.default">
        <field name="model_id" ref="model_product_template" />
        <field name="field_id" eval="1" />
        <field name="json_value">False</field>
        <field name="name">New Action</field>
        <field name="key2">client_action_multi</field>
        <field name="key">action</field>
        <field name="model">product.template</field>
        <field name="value" eval="'ir.actions.server,' + str(ref('new_action1'))" />
    </record>

如果你使用的是 Odoo13.0 那么它会像

If you are using Odoo13.0 then it will be like

       <record id="product_order_new_action1" model="ir.actions.server">
            <field name="name">New Action</field>
            <field name="type">ir.actions.server</field>
            <field name="model_id" ref="model_product_template" />
            <field name="binding_model_id" ref="model_product_template" />
            <field name="state">code</field>
            <field name="code">records.sync_product(False)</field>
        </record>

这篇关于在 Odoo 中创建另一个操作菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆