Community mailing list archives

AW: problem with view inheritance

Josef Kaser
- 03/12/2015 09:53:25

Hi Fabrizio,


this will not work because the two views are using different models (product.template and product.product). An inherited view must use the same model as the parent view.


Kind regards




Von: Fabrizio Mancini []
Gesendet: Donnerstag, 12. März 2015 11:33
An: Community
Betreff: problem with view inheritance


Hi all,

i'm fighting against a problem with the views, and it's driving me crazy!

I'm trying to change the product view (Warehouse - Products- Products).

This is the code for the fields i want to add to the view.



class ProductTemplate(osv.osv):

    _inherit = 'product.template'

    _columns = {

        'anno': fields.integer('Anno')



    def _get_year(self, cr, uid, context=None):



    _defaults = {

        'anno': _get_year,




class ProductProduct(osv.osv):

    _inherit = 'product.product'

    _columns = {

        'codicebarre': fields.char('Codice a Barre GIG (code39)', size=12),

        'codicebarreext': fields.char('Codice a Barre Fornitore', size=150),

        'venduto_euro': fields.float('Venduto (Eur.)', digits=(14, 5))



Nothing complex.

Ok first of all i want to add the "anno" field in the product_template_form_view (i think this is the correct one). I place it after the first group in the "Information" page. In the link there is at the bottom the original view



<record model="ir.ui.view" id="product.product_template_custom_form_view">

    <field name="name">product.template.custom.form</field>

    <field name="model">product.template</field>

    <field name="mode">extension</field>

    <field name="inherit_id" ref="product.product_template_form_view" />

    <field name="arch" type="xml">

        <xpath expr="//page[@string='Information']/group[1]" position="after">

            <group colspan="4">


                    <field name="anno" string="Anno" />







and then the other fields. Here i inherit from the preceding view, but this is probably wrong?


<record model="ir.ui.view" id="product.product_product_custom_form_view">

    <field name="name">product.product.custom.form</field>

    <field name="model">product.product</field>

    <field name="mode">extension</field>

    <field name="inherit_id" ref="product.product_template_custom_form_view" />

    <field name="arch" type="xml">

        <xpath expr="//page[@string='Information']/group[2]/group[1]" position="inside">

                <field name="venduto_euro" />


        <xpath expr="//page[@string='Information']/group[2]" position="inside">


                <field name="codicebarre" />

                <field name="codicebarreext" />







But i can see the "anno" fields but not the other fields. 

The result is the same if i change the inherit_id field and the xpath expression.

So what i am doing wrong?

This is the screenshot

Thanks in advance, any help appreciated


Post to: