如何在Odoo对象上进行继承

如何在Odoo对象上进行继承,odoo,multiple-inheritance,odoo-12,Odoo,Multiple Inheritance,Odoo 12,我正在尝试将Odoo中现有对象的继承(即“mail.alias.mixin”)添加到“utm.campaign”对象中 我试图执行_inherit=[“mail.alias.mixin”,“utm.campaign”],但当我安装模块时,它总是说 File "/home/randy/Odoo/odoo_12/odoo/modules/registry.py", line 180, in __getitem__ return self.models[model_name] KeyError

我正在尝试将Odoo中现有对象的继承(即“mail.alias.mixin”)添加到“utm.campaign”对象中

我试图执行_inherit=[“mail.alias.mixin”,“utm.campaign”],但当我安装模块时,它总是说

File "/home/randy/Odoo/odoo_12/odoo/modules/registry.py", line 180, in __getitem__
    return self.models[model_name]
KeyError: None
以下是我的完整代码:

清单.py


{
    "name": "CRM ext",
    "version": "12.4.0.0.0",
    'author': 'me',
    "description": """
    extend CRM.
    """,
    "depends": [
        'crm',
        'calendar',
        'fetchmail',
        'utm',
        'web_tour',
        'digest',
        'mail',
    ],
    'init_xml': [],
    'data': [
        "security/ir.model.access.csv",
        'data/crm_question.xml',
        'wizard/lost_and_link_partner_crm_wizard_views.xml',
        'views/crm_lead_view.xml',
    ],
    'installable': True,
    'active': False,
    'application': False,
}
还有我的utm.py


from odoo import api, fields, models, SUPERUSER_ID
from odoo.http import request
from odoo.tools import pycompat
from odoo.tools.safe_eval import safe_eval


class Campaign(models.Model):
    _name = "utm.campaign"
    _inherit = ["mail.alias.mixin", "utm.campaign"]

    alias_id = fields.Many2one('mail.alias', string='Alias', ondelete="restrict", required=True, help="The email address associated with this campaign. New emails received will automatically create new leads assigned to the campaign.")
    crm_team_id = fields.Many2one('crm.team', string="CRM Team")


我认为我的继承是正确的,但似乎我遗漏了一些东西。

根据Odoo 12文档,只有设置了_name,才能从多个模型继承。在代码中_name等于父模型,这与不设置name相同。您没有定义新模型,因此无法从多个父对象继承

_继承 如果设置了_name,则表示要从中继承的父模型的名称。如果从单亲继承,则可以是str 如果_name未设置,则要就地扩展的单个模型的名称

我找到了它

所以“mail.alias.mixin”是抽象对象,我错过了这个。所以,我也需要实现所有的抽象方法

希望这能挽救某人的一天