Tag Archives: ValueError: : “name ‘self’ is not defined” whi…

ValueError: : “name ‘self’ is not defined” whi…

Detailed map traversal, teach you to master the complex gremlin query debugging method>>>

Modify res of views/views.xml file_ Model, modify to & lt; field name="res_ model">{}& lt;/ field> {} package in code>

For example, res_ Mode is “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>

Change to


<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">

The action will be returned to the client as the next operation to be performed