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:56 AM 1,728 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?

it work it now

Jhon Felipe Urrego Mejia
on 2/26/14, 4:32 AM

How you made it work?

Marcel Knüpfer
on 3/24/14, 5:46 PM
0
Timo Talvitie
On 1/17/14, 7:48 AM

You should remove the _name = 'sale.order' line from your .py file. Defining the _name is not actually even necessary if you want to simply add new fields to an existing model. The current value is also referring to a different model (sale order instead of sale order line).

You can read more about the different inheritance types here: https://doc.openerp.com/trunk/server/03_module_dev_02/#object-inheritance-inherit

If there's still issues, double-check the xpath expression.

i removed the _name property, but it still doesn't work. changing the xpath to <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/tree[@string='Sales Order Lines']/field[@name='tax_id']" position="after"> hasn o effect also…

Clemens Kroell
on 1/17/14, 8:42 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

0 follower(s)

Stats

Asked: 1/17/14, 6:56 AM
Seen: 1728 times
Last updated: 3/16/15, 8:10 AM