Odoo Help


How to understand inheritance ?

Anabela Damas
on 4/19/16, 5:16 AM 1,382 views


In the new version , odoo v9, I've seen several relations like:

product.product with product.template

res.user with res.partner

account.payment with  account.abstract.payment

I still don't understand this , I thought that if I added a field in account.abstract.payment , that new field would be present in the account.payment , but it doesn't...

In core code we have this: 

class account_abstract_payment(models.AbstractModel):
_name = "account.abstract.payment"
_description = "Contains the logic shared between models which allows to register payments"

class account_register_payments(models.TransientModel):

_name = "account.register.payments"

_inherit = 'account.abstract.payment'

_description = "Register payments on multiple invoices"


class account_payment(models.Model):
_name = "account.payment"
_inherit = 'account.abstract.payment'
_description = "Payments"
_order = "payment_date desc, name desc"

So, I thought that if I do this :

class account_abstract_payment(models.AbstractModel):
_inherit = "account.abstract.payment"  
payment_line_ids = fields.One2many('account.payment.lines', 'payment_id', string='Payment Lines',)

I thougth that I was adding the field to account_register_payments and account_payment. 

But when I implement the view for account_payment:

<record id="view_account_payment_form_saft" model="ir.ui.view">
<field name="name">account.payment.form.saft</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="arch" type="xml">
<sheet position="inside">
<group name="payment_lines" string="Payment Lines">
<field name="payment_line_ids" attrs="{'readonly': [('state', '!=', 'draft')]}"/>

I get this error :

Error details:
Field `payment_line_ids` does not exist

Is there a documentation or something for me to understand how this work? 




Akhil P Sivan

--Akhil P Sivan--

| 5 4 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 4/26/16, 1:03 PM


There are mainly two types of inheritance in Odoo:

- Model inheritance

- View Inheritance

You need to understand them seperately.

Model inheritance can be done in three ways. You may refer the following to understand that:



And to understand view inheritance, you may refer the following:



Maurice Agée
On 4/26/16, 11:13 AM

In your custom module please verify "__open_erp__.py" : you must have a line

'depends': ['account.payment' ,], 

I think you didn't understood my question...

Versão Integral, Anabela Damas
on 4/26/16, 11:19 AM

You must check in your module that you have to declare the module linked to this inheritance otherwise it will not work! After for inheritance, I learn with this question in the forum " The different "openerp model inheritance" mechanisms: what's the difference between them, and when should they be used ? .............................................. https://www.odoo.com/fr_FR/forum/aide-1/question/the-different-openerp-model-inheritance-mechanisms-whats-the-difference-between-them-and-when-should-they-be-used-4

Maurice Agée
on 4/26/16, 11:35 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/19/16, 5:16 AM
Seen: 1382 times
Last updated: 4/26/16, 1:03 PM