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

Multi level view inheritance

By
Mandeep
on 10/18/14, 7:33 AM 1,169 views

Is multi level inheritance of views possible in odoo. e.g.

I have inherited the product template to add "my product type" to all products

class my_products(osv.osv):
    _name = "product.template"
    _inherit="product.template"
    _columns = {
        'my_product_type': fields.char('My Product Type', size=50, required=True),
    }

I have also inherited the view as follows 

        <record model="ir.ui.view" id="product_template_form_view">
            <field name="name">My Products</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_form_view"/>
            <field name="arch" type="xml">
          <notebook position="inside">
        <page string="My Product Details">
          <group>
            <field name="my_product_type"/>
          </group>
        </page>
          </notebook>.....

This works if i go to product create forms. 

However if now i go to create the next level of inheritance by creating a book

class book(osv.osv):
    _name = "book"
    _inherit="product.template"
    _columns = {
        'isbn': fields.char('ISBN', size=30),
     }

and then try to inherit from the form added already for my products

        <record model="ir.ui.view" id="view_books_form">
            <field name="name">Books</field>
            <field name="model">book</field>
            <field name="inherit_id" ref="my_products.product_template_form_view"/>
            <field name="arch" type="xml">
          <notebook position="inside">
        <page string="Book Details">
          <group>
            <field name="isbn"/>
          </group>
        </page>
          </notebook>
            </field>
        </record>    

 

It does not work. None of the two tabs are displayed. If however i do not inherit from my_products.template form but directly from product.template form. The book details tab is added but not the product details. Does multi level inheritance work in this way

 

 

1

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 10/22/14, 1:59 AM

Tel me something, when you inherited product_template in "book" module, for which you given "name" signifying it as an new object.. So the model "book" is a derived object from product_template, and will be treated as a new model...

Hence you need to create new XML views for the object "book", in this case you cannot inherit from its super object view..

Your second case of inherting [book] is obsolutely wrong, You got to understand the behaviour of inheritance... only then you will have a better insight of it...

In Openerp: there are 2 kinds of Inheritance:
  1. Object Inheritance - _inherit
  2. Inheritance by Delegation - _inherits

Do Refer those docs for better info...

 

 

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: 10/18/14, 7:33 AM
Seen: 1169 times
Last updated: 3/16/15, 8:10 AM