Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Adding custom field to sales order product lines?

By
Clemens Kroell
on 1/17/14, 6:45 AM 4,218 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?

1

Atul Kumar jain

--Atul Kumar jain--
914
| 5 3 7
Indore, India
--Atul Kumar jain--

.

Atul Kumar jain
On 3/18/14, 8:08 AM

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>

this will add details field in form and tree both view

Atul Kumar jain
on 3/18/14, 9:13 AM
0

Jagdish Panchal

--Jagdish Panchal--
2674
| 5 3 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 3/19/14, 7:19 AM

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>

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"

Jhon Felipe Urrego Mejia
on 3/19/14, 6:44 PM
0
0
muthunaveen
On 3/18/14, 7:58 AM

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>

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"

Jhon Felipe Urrego Mejia
on 3/19/14, 4:13 AM

Openerp7 obviously

Jhon Felipe Urrego Mejia
on 3/19/14, 4:20 AM

Hi updated answer please try it

charlesraj
on 3/19/14, 7:04 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/17/14, 6:45 AM
Seen: 4218 times
Last updated: 8/27/16, 4:12 AM