gpt4 book ai didi

python - key 错误 : 'crm' when installing custom module in Odoo 8

转载 作者:行者123 更新时间:2023-12-01 03:31:19 24 4
gpt4 key购买 nike

我正在为 Odoo 8 构建一个模块,以将额外字段添加到默认 CRM 模块“机会”部分,但我收到以下错误消息:

Traceback (most recent call last):
File "/opt/odoo/odoo-server/openerp/http.py", line 540, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo-server/openerp/http.py", line 577, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-server/openerp/http.py", line 313, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-server/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-server/openerp/http.py", line 310, in checked_call
return self.endpoint(*a, **kw)
File "/opt/odoo/odoo-server/openerp/http.py", line 806, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo-server/openerp/http.py", line 406, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-server/addons/web/controllers/main.py", line 948, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/odoo/odoo-server/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/odoo-server/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/odoo-server/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/odoo-server/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/odoo-server/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/odoo-server/openerp/modules/registry.py", line 370, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo-server/openerp/modules/loading.py", line 355, in load_modules
loaded_modules, update_module)
File "/opt/odoo/odoo-server/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/odoo-server/openerp/modules/loading.py", line 152, in load_module_graph
models = registry.load(cr, package)
File "/opt/odoo/odoo-server/openerp/modules/registry.py", line 163, in load
model = cls._build_model(self, cr)
File "/opt/odoo/odoo-server/openerp/models.py", line 595, in _build_model
original_module = pool[name]._original_module if name in parents else cls._module
File "/opt/odoo/odoo-server/openerp/modules/registry.py", line 102, in __getitem__
return self.models[model_name]
KeyError: 'crm'

这似乎是一个依赖项错误,但我已经将“crm”添加到我的 openerp.py 文件中。我还提供了我的模块文件信息:

__init__.py

import cant_neg_crm

__openerp__.py

{
'name': 'Cant Neg CRM',
'version': '1.0',
'category': 'Customer Relationship Management',
'summary': 'Leads, Opportunities, Phone Calls',
'description': """

Info
====================================================

Added :
-------------------------------
* Hosting
""",
'author': 'Gigabee',
'website': 'https://gigabee.es',
'depends': ['base','crm',],
'data': [
'cant_neg_crm.xml',
],
'installable': True,
'application': True,
'auto_install': False,
}

cant_neg_crm.py

import openerp
from openerp.osv import fields, osv, orm
from openerp import models


class tipo_facturacion(models.Model):
_name = "tipo_facturacion"
name = fields.char('Tipo', required=True)

class cant_neg_opp(models.Model):
_name = "crm"
_inherit = "crm"
_columns = {
'tiene_dominio': fields.boolean('Tiene dominio(s)'),
'su_dominio': fields.char('Dominio(s)'),

'modo_facturacion': fields.many2one('tipo_facturacion' ,'Tipo Facturacion'),
}

cant_neg_crm.xml

<?xml version="1.0"?>
<openerp>
<data>
<record id="crm_cant_neg_view" model="ir.ui.view">
<field name="name">res.partner.cant_neg_crm.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor" />
<field name="arch" type="xml">
<xpath expr="//page[@string='Internal Notes']" position="after">
<page string="Dominios y Hosting">
<group string="Dominios y Hosting del Cliente">
<field string="¿Tiene dominio?" name="tiene_dominio"/>
<field string="Dominio" name="su_dominio" attrs="{'invisible':[('tiene_dominio', '!=', True)], 'required':[('tiene_dominio', '=', True)]}" />
</group>
</xpath>
</field>
</record>
</data>
</openerp>

预先非常感谢您的帮助!

亲切的问候,

最佳答案

您收到 KeyError: 'crm' 因为您写入 _inherit='crm' 这意味着它会检查数据库中的 crm 对象,但事实并非如此找到了。

您需要改进以下几点。

  1. 没有 crm 对象。它是 crm.lead 对象。删除name属性。

    class cant_neg_opp(models.Model):  
    _inherit = "crm.lead"
    _columns = {
    'tiene_dominio': fields.boolean('Tiene dominio(s)'),
    'su_dominio': fields.char('Dominio(s)'),

    'modo_facturacion': fields.many2one('tipo_facturacion' ,'Tipo Facturacion'),
    }
  2. 将 View 模型名称从 res.partner 更改为 crm.lead

    <?xml version="1.0"?>
    <openerp>
    <data>
    <record id="crm_cant_neg_view" model="ir.ui.view">
    <field name="name">crm.lead.cant_neg_crm.inherit</field>
    <field name="model">crm.lead</field>
    <field name="inherit_id" ref="crm.crm_case_form_view_oppor" />
    <field name="arch" type="xml">
    <xpath expr="//page[@string='Internal Notes']" position="after">
    <page string="Dominios y Hosting">
    <group string="Dominios y Hosting del Cliente">
    <field string="¿Tiene dominio?" name="tiene_dominio"/>
    <field string="Dominio" name="su_dominio" attrs="{'invisible':[('tiene_dominio', '!=', True)], 'required':[('tiene_dominio', '=', True)]}" />
    </group>
    </xpath>
    </field>
    </record>
    </data>
    </openerp>

更多详情,您可以了解Odoo 8 Documentation

关于python - key 错误 : 'crm' when installing custom module in Odoo 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40913888/

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