有没有办法向 Odoo 12 树视图中的操作菜单添加额外的操作? [英] Is there a way to add an extra action to the action menu in tree view in Odoo 12?
问题描述
我正在搜索添加一个新按钮,用于在树视图中的操作按钮显示中显示我的向导
我的向导工作,因为我单独测试过,但我需要将它添加到顶部的操作按钮,我不知道如何
我尝试使用 action.server 但没有找到任何对我有帮助的示例
谢谢
我也知道从 Odoo 10 到 Odoo 12 发生了变化,这就是为什么我没有找到任何线索.
接下来是我尝试过但没有成功的例子
<field name="domain">[]</field><field name="context">{}</field><field name="res_model">pdi.riesgo</field><field name="view_type">form</field><field name="view_mode">form</field><field name="target">new</field></记录><记录模型=ir.actions.server";id=accion_servidor_evaluation"><field name="name">Enviar a evaluacion</field><字段名称=model_id"ref=model_pdi_riesgo_wizard_evaluation"/><field name="state">code</field><字段名称=代码">object.enviar_a_evaluar(context.get('active_ids'))</field></记录>
下次试试
<field name="state">code</field><字段名称=代码">动作=pdi.riesgo.wizard.evaluacion.enviar_a_evaluar()</field></记录><menuitem id="menu_enviar_a_evaluacion";name="Enviar a evaluation";父母=pdi_Riesgo.menu_riesgo_evaluaciones"动作=menu_action_evaluation"/>
新"方法是在动作上设置一些新字段.以下是来自 nofold 的示例:
<!--操作下拉菜单中的标记为丢失"--><record id="action_mark_as_lost";模型=ir.actions.server"><field name="name">标记为丢失</field><字段名称=model_id"ref=model_crm_lead"/><字段名称=binding_model_id"ref=crm.model_crm_lead"/><field name="binding_view_types">list</field><field name="state">code</field><字段名称=代码">如果记录:action_values = env.ref('crm.crm_lead_lost_action').read()[0]action_values.update({'context': env.context})动作 = 动作值</field></记录>
因此模型ir.actions
(由ir.actions.server
继承)上的三个字段都以binding_
<开头/p>
- binding_model_id:设置一个已有模型的引用,足以在动作菜单中显示动作
- binding_type:
report
用于报告菜单,action
用于操作菜单(默认) - binding_view_types:
list,form
是默认的,list
和form
也应该可以工作,我没有研究那个领域,所以也许有更多的组合/值
i am searchin to add a new button that displays my wizard to the action button display in the tree view
My wizard works because i tested it individually, but i need to add it to the action button on the top and i do not know how
I tried to use the action.server but did not find any example that helped me
Thanks
Also i know that from Odoo 10 to Odoo 12 changed, thats why i have not found any clue.
Next are the examples i tried but not succed
<record model="ir.actions.act_window" id="enviar_evaluacion">
<field name="name">enviar_evaluacion</field>
<field name="view_id" ref="vista_formulario_riesgo_para_evaluacion"/>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="res_model">pdi.riesgo</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.actions.server" id="accion_servidor_evaluacion">
<field name="name">Enviar a evaluacion</field>
<field name="model_id" ref="model_pdi_riesgo_wizard_evaluacion"/>
<field name="state">code</field>
<field name="code">
object.enviar_a_evaluar(context.get('active_ids'))
</field>
</record>
next try
<record model="ir.actions.server" id="menu_action_evaluacion">
<field name="name">Enviar a evaluacion</field>
<field name="model_id" ref="model_pdi_riesgo"/>
<field name="state">code</field>
<field name="code">
action=pdi.riesgo.wizard.evaluacion.enviar_a_evaluar()
</field>
</record>
<menuitem id="menu_enviar_a_evaluacion"
name="Enviar a evaluacion"
parent="pdi_Riesgo.menu_riesgo_evaluaciones"
action="menu_action_evaluacion"/>
The "new" way is to set some new fields on actions. Following is an example from Odoo's app crm:
<!--
'Mark as Lost' in action dropdown
-->
<record id="action_mark_as_lost" model="ir.actions.server">
<field name="name">Mark as lost</field>
<field name="model_id" ref="model_crm_lead"/>
<field name="binding_model_id" ref="crm.model_crm_lead"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
if record:
action_values = env.ref('crm.crm_lead_lost_action').read()[0]
action_values.update({'context': env.context})
action = action_values
</field>
</record>
So there are three fields on model ir.actions
(which is inherited by ir.actions.server
) all beginning with binding_
- binding_model_id: set a ref to an existing model, is enough to show the action in the action menu
- binding_type:
report
for the report menu andaction
for the action menu (default) - binding_view_types:
list,form
is default,list
andform
should also work, i didn't look into that field, so maybe there are way more combinations/values
这篇关于有没有办法向 Odoo 12 树视图中的操作菜单添加额外的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!