This question has been flagged
10 Replies
15115 Views

hi,

i try to add a custom text field "detail" to the product lines in a sales order. i created a new module and added the following code:

__init__.py

import sales_order_detail_field

sales_order_detail_field.py

from openerp.osv import fields, osv

class sales_order_detail_field(osv.Model):
        _name = 'sale.order'
        _inherit = 'sale.order.line'
        _columns = {
                'detail': fields.text('Detail'),
        }

sales_order_detail_field(

sales_order_detail_field.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
   <record model="ir.ui.view" id="detail_field_in_view">
    <field name="name">New Sale Order field detail</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
    <xpath expr="//field[@name='order_line']/form/notebook/page[@string='Order Line']//field[@name='product_uom_qty' ]" position="before">
        <field name="detail" />
    </xpath>
    </field>
</record>
    </data>
</openerp>

but when i reload my openerp window, i jus tget the following error

raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Fehler w\xe4hrend der Pr\xfcfung des Feldes field(s) arch: Invalid XML for View Architecture!')

any advice what's wrong here? maybe the xml?

Avatar
Discard
Best Answer

you can try this hope it will solve your problem

<record id="view_res_sale_line_form1" model="ir.ui.view">
    <field name="name">sale.order.line.form.inherit</field>
    <field name="model">sale.order</field>
    <field name="type">form</field>
    <field name="priority" eval="8"/>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <data>
            <xpath expr="//field[@name='product_uom_qty']" position="after">
                <field name="detail"/>

            </xpath>
            <xpath expr="//tree/field[@name='product_uom_qty']" position="after">
                <field name="detail"/>
            </xpath>
        </data> 
    </field>
Avatar
Discard

this will add details field in form and tree both view

Best Answer

you can try this code in .xml file

<record id='view_sale_quotation_from' model='ir.ui.view'>

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

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

     <field name="type">form</field>

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

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

         <data>

             <xpath expr="//notebook/page/field[@name='order_line']/tree[@string='Sales Order Lines']/field[@name='product_uom_qty']" position="before">

         <field name="detail"/>

             </xpath>

         </data>

       </field>

</record>

Avatar
Discard
Best Answer
Avatar
Discard
Best Answer

Try the below once and let me know ur result

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
   <record model="ir.ui.view" id="detail_field_in_view">
    <field name="name">sale_order.line.form2</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
                                <field name="product_uom_qty" position="before">
                                           <field name="Detail"/>
                                </field>
                              </field>
                   </record>
    </data>
</openerp>
Avatar
Discard

i test it and this error show me: " File "lxml.etree.pyx", line 3196, in lxml.etree.parse (src/lxml/lxml.etree.c:64039) File "parser.pxi", line 1571, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:91476) File "parser.pxi", line 1601, in lxml.etree._parseFilelikeDocument (src/lxml/lxml.etree.c:91798) File "parser.pxi", line 1484, in lxml.etree._parseDocFromFilelike (src/lxml/lxml.etree.c:90682) File "parser.pxi", line 1047, in lxml.etree._BaseParser._parseDocFromFilelike (src/lxml/lxml.etree.c:87736) File "parser.pxi", line 565, in lxml.etree._ParserContext._handleParseResultD"

Openerp7 obviously

Hi updated answer please try it

Best Answer

Hi

I have update code try this.

<record model="ir.ui.view" id="sale_detail_sale_order_line">
    <field name="name">sale.order.line.detail.view.form</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="after">
            <field name="detail"/>
        </xpath>
    </field>
</record>

<record model="ir.ui.view" id="sale_detail_sale_order_line_form">
    <field name="name">sale.order.line.tree.detail.view.form</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
       <xpath expr="//field[@name='order_line']/tree//field[@name='price_unit']" position="after">
            <field name="detail"/>
        </xpath>
    </field>
</record>
Avatar
Discard

Still error: "OpenERP Server Error Client Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, *self.params) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1132, in call_button action = self._call_kw(req, model, method, args, {}) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1120, in _call_kw return getattr(req.session.model(model), method)(args, **kwargs) File "/opt/openerp/server/openerp/addons/web/session.py", line 42, in prox"