How to make a class (which already exists) inherit another class?

For example, a class res.partner. I want the res.partnerclass to inherit A. How to do it?

I do not think this will work:

class custom_res_partner(osv.osv):

    _name           = "res.partner"
    _inherit        = "A"

custom_res_partner()
+4
source share
3 answers

If the model is already present and you want it to inherit another model, it should be done as follows:

class custom_res_partner(osv.osv):
    _name = "res.partner"
    _inherit = ['res.partner', 'A']

_namethe important part here is that Odoo knows which model inherits from it. in _inherityou also need to specify res.partner, because you expand this model.

+2
source
class custom_res_partner(osv.osv):

    _name           = "custom.res.partner"    # New Model will be created
    _inherit        = "A"   # Base class 

custom_res_partner()

(), . res.partner, .

+1
# odoo-8
from openerp import fields, models, api, _
class res_partner(models.Model):
    _inherit = "A"

EDIT: (This is for version 8) Create a new module and inherit the model Ain the python file in the module. To create a new module, refer to Create an Odoo Module

+1
source

All Articles