This question has been flagged
5 Replies
12945 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 

 






Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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

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

Avatar
Discard
Author

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

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