Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4709 Näkymät

i want to add a field to the sale.order view 

i proceed this way for the declaration of the field on the model.py 

class SaleOrderLine(models.Model):

    _inherit = 'sale.order.line'

    prf = fields.Char(string='prf')


and on the view form the fallowing :

<?xml version="1.0" encoding="utf-8" ?>

<!-- License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

     Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. -->

<odoo>

    <data>

                <record model="ir.ui.view" id="sale_order_view_inherit">

                <field name="name">sale.order.view.inherit1</field>

                <field name="model">sale.order</field>

                <field name="inherit_id" ref="sale.view_order_form"/>

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

                    <xpath expr="//form/sheet/notebook/page[@string='Other Information']/group/group[@string='Sales Information']/field[@name='user_id']" position="after">

                        <field name="prf"/>

                    </xpath>

                </field>

            </record>

    </data>

</odoo>


but the server persiste on showing this error, i think i still have an issue on the xpath structure. don't you think ? 


Avatar
Hylkää

to inherit and add a field in existing view: https://www.youtube.com/watch?v=46yecsKX2tw

Paras vastaus

Hi:

As far as possible, you should avoid using "string" in your xpath expression since these can get changed at any point in time. Attributes like "name" are more suitable for use in the xpath expression.

Change your xpath to the following and it should work.

    <xpath expr="/form/sheet/notebook/page[@name='other_information']/group/group[@name='sales_person']/field[@name='user_id']" position="after">
        <field name="prf"/>
    </xpath>


Avatar
Hylkää

string is not valid anymore, I don't remember since which version.

Tekijä Paras vastaus

it works like Magic, Thanks a lot !

Avatar
Hylkää

The proper way to thank for help in this forum is to check it as anwered and to upvote the help. No need to post an answer for that.

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
maalisk. 24
1199
1
marrask. 18
8224
5
huhtik. 16
5890
2
huhtik. 25
2307
1
helmik. 25
696