Odoo Help

Welcome!

This community 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.

0

How to understand inheritance ?

By
Anabela Damas
on 4/19/16, 5:16 AM 475 views

Hello, 

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')]}"/>
</group>
</sheet>
</field>
</record>

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? 

Thanks 

 






2

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
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

Hi,

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:

https://www.odoo.com/documentation/8.0/howtos/backend.html#model-inheritance

https://www.odoo.com/forum/how-to/developers-13/the-different-openerp-model-inheritance-mechanisms-whats-the-difference-between-them-and-when-should-they-be-used-46


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

https://www.odoo.com/documentation/8.0/reference/views.html#inheritance

https://www.odoo.com/documentation/8.0/howtos/backend.html#view-inheritance

0
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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