我正在尝试将Project issue模块从Odoo 8移植到Odoo 10,以便为项目添加版本字段。
project_version.py:
class project_version(models.Model):
_inherit = 'project.project'
_name = "project.version"
_order = "name desc"
_columns = {
'name': fields.char('Version Number', required=True),
'active': fields.boolean('Active', required=False),
}
_defaults = {
'active': 1,
}
当我尝试安装它时,Odoo说
Model not found: project.project.version
Error context:
View `project_version list`
[view_id: 750, xml_id: n/a, model: project.project.version, parent_id: n/a]
None" while parsing file:///c:/Program%20Files%20(x86)/Odoo%2010.0/server/custom/project_task_version/views/views.xml:9, near
<record model="ir.ui.view" id="project_version.list">
<field name="name">project_version list</field>
<field name="model">project.version</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="active"/>
</tree>
</field>
</record>
答案 0 :(得分:1)
此错误意味着,Odoo无法找到您的模型。正如我所见,你将名称“project.version”设置为模型,但是Odoo搜索“project.project.version”。因此,只需尝试将模型名称从“project.version”更改为“project.project.version”。 下一个: 现在,Odoo 10不支持这种类型的模型声明:
_columns = { 'name':fields.char('Version Number',required = True), 'active':fields.boolean('Active',required = False),}
尝试查看此文档 - https://www.odoo.com/documentation/10.0/howtos/backend.html#model-fields
答案 1 :(得分:0)
您必须通过以下内容替换声明_columns和_default:您使用的声明来自旧的API语法。
关于字段属性的语法应如下所示:
name = fields.Char('Version Number', required=True)
active = fields.Boolean('Active', required=True, default=True)