gpt4 book ai didi

python - 无法继承OpenERP中的HR.Employee

转载 作者:太空宇宙 更新时间:2023-11-03 19:03:23 32 4
gpt4 key购买 nike

请告诉我我的错误在哪里。我需要添加一个名为 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()

这是我的错误:

Traceback (most recent call last):
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py", line 226, in execute
res = self._obj.execute(query, params)
IntegrityError: null value in column "res_model" violates not-null constraint

2013-03-18 04:10:16,830 4709 ERROR OpenERP_DB openerp.tools.convert: Parse error in /home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/checkroll/checkroll_view.xml:179:

checkroll.daily.update.form
checkroll.daily.update
form
form

Traceback (most recent call last):
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py", line 847, in parse
self._tags[rec.tag](self.cr, rec, n)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py", line 814, in _tag_record
id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/base/ir/ir_model.py", line 964, in _update
res_id = model_obj.create(cr, uid, values, context=context)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/orm.py", line 4434, in create
cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py", line 161, in wrapper
return f(self, *args, **kwargs)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py", line 226, in execute
res = self._obj.execute(query, params)
IntegrityError: null value in column "res_model" violates not-null constraint

2013-03-18 04:10:16,835 4709 ERROR OpenERP_DB openerp.netsvc: null value in column "res_model" violates not-null constraint
Traceback (most recent call last):
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/netsvc.py", line 293, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/service/web_services.py", line 425, in dispatch
return fn(*params)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/service/web_services.py", line 436, in exp_authenticate
res_users = pooler.get_pool(db).get('res.users')
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/pooler.py", line 49, in get_pool
return get_db_and_pool(db_name, force_demo, status, update_module)[1]
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/pooler.py", line 33, in get_db_and_pool
registry = RegistryManager.get(db_name, force_demo, status, update_module)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/registry.py", line 192, in get
update_module)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/registry.py", line 218, in new
openerp.modules.load_modules(registry.db, force_demo, status, update_module)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py", line 344, in load_modules
processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules, update_module)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py", line 259, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py", line 190, in load_module_graph
load_update_xml(module_name, idref, mode)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py", line 74, in
load_update_xml = lambda *args: _load_data(cr, *args, kind='update_xml')
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py", line 127, in _load_data
tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py", line 954, in convert_xml_import
obj.parse(doc.getroot())
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py", line 847, in parse
self._tags[rec.tag](self.cr, rec, n)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/tools/convert.py", line 814, in _tag_record
id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/base/ir/ir_model.py", line 964, in _update
res_id = model_obj.create(cr, uid, values, context=context)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/orm.py", line 4434, in create
cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py", line 161, in wrapper
return f(self, *args, **kwargs)
File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/sql_db.py", line 226, in execute
res = self._obj.execute(query, params)
IntegrityError: null value in column "res_model" violates not-null constraint

2013-03-18 04:10:16,847 4709 INFO OpenERP_DB werkzeug: 127.0.0.1 - - [18/Mar/2013 04:10:16] "POST /web/session/authenticate HTTP/1.1" 200 -

最佳答案

你的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.每日更新 形式

需要使用 xpath 或字段标记定义要添加此字段的位置

希望这有帮助

关于python - 无法继承OpenERP中的HR.Employee,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15469954/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com