- 修改views/views.xml文件的res_model, 修改为
<field name="res_model">{}</field>
中的{}
包裹的内容
- 例, 其中res_mode为"em.em"
<odoo>
<data>
<!-- actions opening views on models -->
<record model="ir.actions.act_window" id="em.action_window">
<field name="name">em window</field>
<field name="res_model">em.em</field>
<field name="view_mode">tree,form</field>
</record>
<!-- server action to the one above -->
<record model="ir.actions.server" id="em.action_server">
<field name="name">em server</field>
<field name="model_id" ref="model_em_em"/>
<field name="state">code</field>
<field name="code">
action = {
"type": "ir.actions.act_window",
"view_mode": "tree,form",
<!--change here-->
"res_model": self._name,
}
</field>
</record>
<odoo>
<data>
<!-- actions opening views on models -->
<record model="ir.actions.act_window" id="em.action_window">
<field name="name">em window</field>
<field name="res_model">em.em</field>
<field name="view_mode">tree,form</field>
</record>
<!-- server action to the one above -->
<record model="ir.actions.server" id="em.action_server">
<field name="name">em server</field>
<field name="model_id" ref="model_em_em"/>
<field name="state">code</field>
<field name="code">
action = {
"type": "ir.actions.act_window",
"view_mode": "tree,form",
<!--change here-->
"res_model": "em.em",
}
</field>
</record>
<field name="code">
包裹的内容是py代码
- 其中的action,将作为下一个要执行的操作返回给客户端