无法在OpenERP中继承HR.Employee

时间:2013-03-18 04:50:44

标签: python xml openerp

请告诉我我的错误在哪里。我需要添加一个名为kanganyname的新字段(经理名称)。但它给了我一个错误。我按照开发者指南进行了修改:

这是我的view.xml

<record model="ir.ui.view" id="namelist_dailyupdate">
    <field name="name">checkroll.daily.update.form</field>
    <field name="model">checkroll.daily.update</field>
    <field name="inherit_id" ref="hr.view_employee_form" />
    <field name="type">form</field>
    <field name="arch" type="xml">
        <form string="daily_update">
            <field name="kanganyname" />
        </form>
    </field>
</record>

<record model="ir.actions.act_window" id="action_inherit_ex">
    <field name="name">checkroll.daily.update.form</field>
    <field name="model">checkroll.daily.update</field>
    <field name="view_type">form</field>
    <field name="view_mode">form</field>
</record>

这是我的模特课。

class dailyupdate(osv.osv):
    _name = "checkroll.daily.update"
    _inherit = "hr.employee"
    _description = "This table is for daily update"
    _columns = {
        'kanganyname': fields.char('Kangany Name', size=256, required=True)
    }

dailyupdate()

这是我的错误:

  

追踪(最近的呼叫最后):
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py" ;,第226行,执行中
         res = self._obj.execute(query,params)
     IntegrityError:列中的空值&#34; res_model&#34;违反非空约束
     
     2013-03-18 04:10:16,830 4709错误OpenERP_DB openerp.tools.convert:/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/checkroll/checkroll_view.xml:179中的解析错误:登记/>      
                 checkroll.daily.update.form
                 checkroll.daily.update
                 形成
                 形成
             
     追溯(最近的呼叫最后):
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py" ;,第847行,在解析中          self._tags [rec.tag](self.cr,rec,n)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py",第814行,在_tag_record中          id = self.pool.get(&#39; ir.model.data&#39;)._ update(cr,self.uid,rec_model,self.module,res,rec_id或False,not self.isnoupdate(data_node), noupdate = self.isnoupdate(data_node),mode = self.mode,context = rec_context)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/base/ir/ir_model.py" ;,第964行,在_update中          res_id = model_obj.create(cr,uid,values,context = context)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/orm.py" ;,第4434行,在创建中          cr.execute(&#39;插入&#34;&#39; + self._table +&#39;&#34;(id&#39; + upd0 +&#34;)值(&#34; + str(id_new)+ upd1 +&#39;)&#39;,tuple(upd2))
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py" ;,第161行,在包装中          返回f(self,* args,** kwargs)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py" ;,第226行,执行中
         res = self._obj.execute(query,params)
     IntegrityError:列中的空值&#34; res_model&#34;违反非空约束
     
     2013-03-18 04:10:16,835 4709错误OpenERP_DB openerp.netsvc:列中的空值&#34; res_model&#34;违反非空约束
     追溯(最近的呼叫最后):
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/netsvc.py" ;,第293行,在dispatch_rpc中          result = ExportService.getService(service_name).dispatch(method,params)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/service/web_services.py" ;,第425行,在发货中          返回fn(* params)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/service/web_services.py" ;,第436行,在exp_authenticate中          res_users = pooler.get_pool(db).get(&#39; res.users&#39;)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/pooler.py" ;,第49行,在get_pool中          return get_db_and_pool(db_name,force_demo,status,update_module)[1]
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/pooler.py",第33行,在get_db_and_pool中          registry = RegistryManager.get(db_name,force_demo,status,update_module)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/registry.py" ;,第192行,获取中          update_module)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/registry.py" ;,第218行,新增内容          openerp.modules.load_modules(registry.db,force_demo,status,update_module)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py" ;,第344行,在load_modules中
         processed = load_marked_modules(cr,graph,states_to_load,force,status,report,loaded_modules,update_module)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py" ;,第259行,在load_marked_modules中
         loaded,processed = load_module_graph(cr,graph,progressdict,report = report,skip_modules = loaded_modules,perform_checks = perform_checks)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py" ;,第190行,在load_module_graph中          load_update_xml(module_name,idref,mode)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py" ;,第74行,在中          load_update_xml = lambda * args:_load_data(cr,* args,kind =&#39; update_xml&#39;)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py" ;,第127行,在_load_data中          tools.convert_xml_import(cr,module_name,fp,idref,mode,noupdate,report)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py",第954行,在convert_xml_import中          obj.parse(doc.getroot())
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py" ;,第847行,在解析中          self._tags [rec.tag](self.cr,rec,n)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py",第814行,在_tag_record中          id = self.pool.get(&#39; ir.model.data&#39;)._ update(cr,self.uid,rec_model,self.module,res,rec_id或False,not self.isnoupdate(data_node), noupdate = self.isnoupdate(data_node),mode = self.mode,context = rec_context)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/base/ir/ir_model.py" ;,第964行,在_update中          res_id = model_obj.create(cr,uid,values,context = context)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/orm.py" ;,第4434行,在创建中          cr.execute(&#39;插入&#34;&#39; + self._table +&#39;&#34;(id&#39; + upd0 +&#34;)值(&#34; + str(id_new)+ upd1 +&#39;)&#39;,tuple(upd2))
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py" ;,第161行,在包装中          返回f(self,* args,** kwargs)
       文件&#34; /home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py" ;,第226行,执行中
         res = self._obj.execute(query,params)
     IntegrityError:列中的空值&#34; res_model&#34;违反非空约束
     
     2013-03-18 04:10:16,847 4709 INFO OpenERP_DB werkzeug:127.0.0.1 - - [18 / Mar / 2013 04:10:16]&#34; POST / web / session / authenticate HTTP / 1.1&#34; 200 -

1 个答案:

答案 0 :(得分:1)

你的xml代码完全没有继承。

<record model="ir.ui.view" id="namelist_dailyupdate">
    <field name="name">checkroll.daily.update.form</field>
    <field name="model">checkroll.daily.update</field>
    <field name="inherit_id" ref="hr.view_employee_form" />
    <field name="type">form</field>
    <field name="arch" type="xml">
        <form string="daily_update">
            <field name="kanganyname" />
        </form>
    </field>
</record>

在您的代码中,您没有指定要添加新字段的位置,您可以像这样定义代码

<record model="ir.ui.view" id="namelist_dailyupdate">
    <field name="name">checkroll.daily.update.form</field>
    <field name="model">checkroll.daily.update</field>
    <field name="inherit_id" ref="hr.view_employee_form" />
    <field name="type">form</field>
    <field name="arch" type="xml">
        <form string="daily_update">
            <xpath expr="//field[@name='name']" position="after">
                <field name="kanganyname" />
           </xpath>
        </form>
   </field>
</record>

    checkroll.daily.update.form     checkroll.daily.update          形成                                                                     

需要使用xpath或field tag

定义要添加此字段的位置

希望这个帮助