Community mailing list archives

Re: problem with view inheritance

OpusVL, Nuria Arranz-Velazquez
- 03/12/2015 08:08:01

What colspan are you using on the other 3 fields?


On 12/03/15 10:32, Fabrizio Mancini wrote:
<blockquote cite="" type="cite">
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:

N. Arranz-Velazquez
OpusVL Odoo Specialist Team (OOST)

Drury House
Drury Lane
CV21 3DE

T: 01788 298 450