Reputation: 11
I'm trying to add inheritance on existing object in Odoo, which is "mail.alias.mixin" into "utm.campaign" object.
I tried to do _inherit = ["mail.alias.mixin", "utm.campaign"] but when I install my module it always said
File "/home/randy/Odoo/odoo_12/odoo/modules/registry.py", line 180, in __getitem__
return self.models[model_name]
KeyError: None
Here is my code in full:
manifest.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,
}
And my 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")
I except that my inheritance is correct, but It seems that I missing something.
Upvotes: 1
Views: 1476
Reputation: 11
I found it,
So "mail.alias.mixin" are abstract object, I miss this one. So, I need to implement all the abstract method too.
Hope this can save someone's day!
Upvotes: 0
Reputation: 405
According to Odoo 12 documentation you can inherit from multiple models only if _name is set. In your code _name is equal to parent model and that is same as not setting name. You're not defining new model so you can not inherit from multiple parents.
https://www.odoo.com/documentation/12.0/reference/orm.html#reference-orm-inheritance
_inherit If _name is set, names of parent models to inherit from. Can be a str if inheriting from a single parent If _name is unset, name of a single model to extend in-place
Upvotes: 1