ValueError: : "name 'self' is not defined" wh

  • 修改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>
上一篇:二分图染色(模板)


下一篇:C++11中多线程