Odoo 服务器引发错误模块 CRM 在您的系统上不可用

Odoo server raises error Module CRM is not available on your system

我是模块开发的新手。我想向现有 crm_lead 对象添加属性和功能。正在处理 8.0 版本。

我创建了一个具有脚手架功能的新模块。在 __openerp__.py 清单中,我添加了一个依赖项

# any module necessary for this one to work correctly
'depends': ['base','CRM'],

尝试导入模块时出现错误

 raise orm.except_orm(_('Error'), _("You try to install module '%s' that depends on module '%s'.\nBut the latter module is not available in your system.") % (module.name, dep.name,)) 
except_orm: (u'Error', u"You try to install module 'yvleads' that depends on module 'CRM'.\nBut the latter module is not available in your system.")

这是 class 的骨架。我尝试了各种导入(从 openerp、从 CRM、导入 crm、导入 crm_lead),但都没有成功。

class yvleads(models.Model):
    _inherit = 'crm.crm_lead'
    _name = 'yvleads.yvleads'
    name = fields.Char()
    _column = { 'Last_Action': fields.Char('Last_Action', size=240, required=False) }

这里有任何提示或 link 良好实践文档或代码示例以覆盖现有标准模块或向现有标准模块添加信息吗?

谢谢

您只需将模块名称作为一个包,因此 CRM 为小写:

'depends': ['base', 'crm'],

您实际上可以在其他默认插件模块中看到它,例如 crm_claim/__openerp__.py 为标准 crm 模块添加了一些功能。

对于class 代码本身,_inherit 属性需要引用正确的模式名称,即crm_lead 模型的_name 属性。这是更正后的 class 代码

from openerp import models, fields, api
from openerp.addons.crm import crm_lead

class yvleads(models.Model):
    _inherit = 'crm.lead'
    _name = 'yvleads.yvleads'
    name = fields.Char()
    _column = { 'Last_Action': fields.Char('Last_Action', size=240, required=False) }