Skip to Content
Menu
This question has been flagged
6 Replies
4379 Views

i tray to add a new filed to the second page named "inventory" after the field "volume" of the product view

my python code is

# -*- coding: utf-8 -*-

from odoo import api, fields,  models, _


class approvisionnement(models.Model):  
    _inherit = "product.template"
   
    voyage =fields.Integer('voyage')

/////////////////////////////////////////////////

my xml code is

<?xml version="1.0"?>
<odoo>
<!-- from view -->
    <record id="product_normal_form_view1" model="ir.ui.view">
        <field name="name">product.product.form1</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.product_normal_form_view" />
        <field name="type">form</field>
        <field name="arch" type="xml">
            <data>
       
              
               <xpath expr="//field[@name='volume']" position="after">
                     
                        <field name="voyage" string="voyage"/>
                   
               </xpath>
                    
               
                               
            </data>
           
      </field>
   </record>
 </odoo>
Avatar
Discard
thanks for your replay
didn't work it can't locate the xpath
error
"ParseError: "Erreur lors de la validation de la contrainte

L'\xe9l\xe9ment '<xpath expr="/form/sheet/notebook/page/group[@name='inventory']/group/div[@name='volume']">' ne peut \xeatre localis\xe9 dans la vue parente

Contexte de l'erreur :
Vue `product.template.normal.form1.inherit`
[view_id: 745, xml_id: n/a, model: product.template, parent_id: 308]
None" while parsing /home/smartguy/Documents/LiClipse Workspace/odoo10/odoo/addons_amal/ciment/views/ciment_views.xml:4, near
<record id="product_template_form_view1_inherit" model="ir.ui.view">
        <field name="name">product.template.normal.form1.inherit</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_only_form_view"/>
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/notebook/page/group[@name='inventory']/group/div[@name='volume']" position="after">
                <field name="voyage"/>
            </xpath>
        </field>
    </record>"



De : Jignesh Mehta <mj.jignesh@gmail.com>
À : amal <jenni.amal@yahoo.fr>
Envoyé le : Samedi 3 juin 2017 6h36
Objet : how to add a new filed to the second page of product_view

A new question how to add a new filed to the second page of product_view on Help has been posted. Click here to access the question :


Sent by Odoo S.A. using Odoo.


no chnage :( didn't work



De : ayman mohammed adam <ayman_king2000@hotmail.com>
À : amal <jenni.amal@yahoo.fr>
Envoyé le : Dimanche 4 juin 2017 7h15
Objet : Re: how to add a new filed to the second page of product_view

A new answer on how to add a new filed to the second page of product_view has been posted. Click here to access the post :
--
ayman mohammed adam

Sent by Odoo Inc. using Odoo.


Best Answer

Dear amal,

Try to remove the data tags   (<data>       ......              </data>) from your Xml code and upgrade.


I hope I helped you...

Avatar
Discard
Best Answer

I think you are inheriting wrong id

try this, it works for me in v10

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

If it does'nt work check for the xml record which is defining the field volume and inherit it

Avatar
Discard
Best Answer

Hello Amal,

Try this,


<?xml version="1.0"?>
<odoo>

    <record id="product_template_form_view1_inherit" model="ir.ui.view">
        <field name="name">product.template.normal.form1.inherit</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_form_view"/>
        <field name="arch" type="xml">
            <xpath expr="/form/sheet/notebook/page/group[@name='inventory']/group/div[@name='volume']" position="after">
                <field name="voyage"/>
            </xpath>
        </field>
    </record>

 </odoo>


Hope it will works for you.

Thanks,

Avatar
Discard
Best Answer

Hi Amal ,
You are code is almost correct , According to Odoo v10 ( i think its same for v9 and v8 also) you have to give ref as "product.product_template_only_form_view".

So you may replace the line as below

<field name="inherit_id" ref="product.product_template_only_form_view"/>
Avatar
Discard
Author Best Answer

thank you for your replay
i also try with "product.product_template_only_form_view"

it didn't work it give an error of "can't locat "volume" in the parent view"

Avatar
Discard