我为odoo 8开发了一个模块。 当我尝试部署它时,我收到了这个错误:
Traceback (most recent call last):
File "/opt/odoo/openerp/http.py", line 539, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/openerp/http.py", line 576, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/openerp/http.py", line 312, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/openerp/http.py", line 309, in checked_call
return self.endpoint(*a, **kw)
File "/opt/odoo/openerp/http.py", line 805, in __call__
return self.method(*args, **kw)
File "/opt/odoo/openerp/http.py", line 405, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/addons/web/controllers/main.py", line 948, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/odoo/addons/web/controllers/main.py", line 936, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/addons/base/module/module.py", line 447, in button_immediate_install
return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
File "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/addons/base/module/module.py", line 495, in _button_immediate_function
registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
File "/opt/odoo/openerp/modules/registry.py", line 370, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/openerp/modules/loading.py", line 355, in load_modules
loaded_modules, update_module)
File "/opt/odoo/openerp/modules/loading.py", line 255, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo/openerp/modules/loading.py", line 176, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/opt/odoo/openerp/modules/loading.py", line 118, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/opt/odoo/openerp/tools/convert.py", line 900, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/opt/odoo/openerp/tools/convert.py", line 986, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/opt/odoo/openerp/tools/convert.py", line 852, in parse
self._tags[rec.tag](self.cr, rec, n, mode=mode)
File "/opt/odoo/openerp/tools/convert.py", line 762, in _tag_record
id = self.pool['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 "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/addons/base/ir/ir_model.py", line 1065, in _update
res_id = model_obj.create(cr, uid, values, context=context)
File "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/addons/base/ir/ir_ui_view.py", line 255, in create
context=context)
File "/opt/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/api.py", line 372, in old_api
result = method(recs, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 4093, in create
record = self.browse(self._create(old_vals))
File "/opt/odoo/openerp/api.py", line 266, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/openerp/api.py", line 508, in new_api
result = method(self._model, cr, uid, *args, **old_kwargs)
File "/opt/odoo/openerp/models.py", line 4284, in _create
recs._validate_fields(vals)
File "/opt/odoo/openerp/api.py", line 266, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 1271, in _validate_fields
raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition
Error details:
Field `note` does not exist
Error context:
View `hr.skill form`
[view_id: 1027, xml_id: n/a, model: hr.skill, parent_id: 849]" while parsing /opt/odoo/addons/nge_skills_management/skill.xml:32, near
<record id="view_skill_form_inherit" model="ir.ui.view">
<field name="model">hr.skill</field>
<field name="inherit_id" ref="hr_skill.view_skill_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="note" string="Note"/>
</xpath>
</field>
</record>
但是当我检查我的数据库时,我找到了注释字段:
select * from nge_skills_management_hr_skill;
id | parent_left | parent_right | create_uid | create_date | name | write_uid | note | parent_id | write_date | active
----+-------------+--------------+------------+-------------+------+-----------+------+-----------+------------+--------
有我的源代码:
skill.py
from openerp import api, fields, models
class hr_skill(models.Model):
_inherit = "hr.skill"
_name = "nge_skills_management.hr_skill"
note = fields.Selection([('a', '3'),('b', '2'),('c', '1')])
skill.xml
<menuitem id="main_skill_menu" name="Nge Skills" />
<menuitem id="skill_menu" name="My skills"
parent="main_skill_menu" />
<record id="action_home_page" model="ir.actions.client">
<field name="name">Skill Home</field>
<field name="tag">nge_skills_management.homepage</field>
</record>
<menuitem id="home_page_skill_menu" name="Home Page" parent="skill_menu"
action="action_home_page"/>
<record model="ir.actions.act_window" id="nge_skills_action">
<field name="name">NGE Skills</field>
<field name="res_model">hr.skill</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[["parent_id.name", "=", "Programmation"]]</field>
</record>
<record id="view_skill_form_inherit" model="ir.ui.view">
<field name="model">hr.skill</field>
<field name="inherit_id" ref="hr_skill.view_skill_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="note" string="Note"/>
</xpath>
</field>
</record>
<menuitem id="nge_skills_action_menu" name="NGE SKILLS" parent="skill_menu"
action="nge_skills_action"/>
任何人都可以帮助我!!
答案 0 :(得分:1)
在odoo中指定_name
在数据库中创建一个新表(模块的名称是数据库表的名称,.
替换为_
)。
您正在使用的问题是:
_name = 'nge_skills_management.hr_skill'
将创建一个包含hr.skill
字段的新表,并向其添加备注字段而不是hr_skill
模块
你想要什么(正常继承)只是指定_inherit='hr.skill'
。这将使您能够向hr.skill
模型