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

How to set serial numbers for the sale order line

By
nishad
on 8/7/13, 6:24 AM 2,672 views

I want to inherit the existing sale module in to my new custom module which extends current sale module and adds a serial number column to my sale order line tree. But it throws an error like as follows , where am i went wrong ?

 File "parser.pxi", line 1468, in lxml.etree._parseDocFromFilelike (src/lxml/lxml.etree.c:81783)
 File "parser.pxi", line 1024, in lxml.etree._BaseParser._parseDocFromFilelike (src/lxml/lxml.etree.c:78830)
 File "parser.pxi", line 569, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:74567)
 File "parser.pxi", line 650, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:75458)
 File "parser.pxi", line 590, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:74791)
 XMLSyntaxError: AttValue: " or ' expected, line 31, column 28

view.py

        <record id="view_order_line_tree2" model="ir.ui.view">
        <field name="name">sale.order.line.tree.inherit</field>
        <field name="model">sale.order.line</field>
        <field name="inherit_id" ref=sale.view_order_form/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='order_line']/tree" position="attributes">
                <attribute name="sl_no"/>
            </xpath>
        </field>
       </record>

sale_modified.py file contents

    class sale_order_line2(osv.osv):

            _inherit = 'sale.order.line'

           _columns = {
              'sl_no': fields.integer("SL No", required=True)
                  }

             _defaults = {
                  'sl_no':1,
                   }

Any hint to solve the above mentioned issue is appreciated .. Thanks in advance

1
Xsias
On 8/7/13, 6:59 AM

Are you sure that expr="//field[@name='order_line']/tree" is correct ? Try expr="//field[@name='order_line']".

==========

EDIT

Try this :

<record id="view_order_line_tree2" model="ir.ui.view">
        <field name="name">sale.order.line.tree.inherit</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='product_id']" position="before">
                <field name="sl_no"/>
            </xpath>
        </field>
</record>

I tried this case but its not working....

nishad
on 8/7/13, 8:26 AM

Can you try my edit ?

Xsias
on 8/7/13, 9:43 AM

Hi Xsias , it works but a small change , instead of model "sale.order.line" we have to look in to "sale.order" ..... Thanks for your "xpath" expression too....... Hurray....... Thanks all..

nishad
on 8/7/13, 10:14 AM

"correct 1"

nishad
on 8/7/13, 10:14 AM

I have edited with your comment. If it does work, don't hesitate to mark the answer as correct. This is to facilitate users future search.

Xsias
on 8/7/13, 10:42 AM

This works perfect, but you can't edit the field in the lines right now

wizardz
on 10/8/15, 6:10 AM
0

Hiral Patel (hip)

--Hiral Patel (hip)--
Tiny ERP Pvt Ltd
http://www.odoo.com
913
| 2 1 5
India
--Hiral Patel (hip)--


Hiral Patel (hip)
On 8/7/13, 8:59 AM

Hello,

Just replace <xpath> </xpath> with :

<record id="view_sale_orderfor" model="ir.ui.view">
    <field name="name">sale.order.form.inherit5</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <field name="product_id" position="before">
            <field name="sl_no"/>
        </field>
        <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/tree[@string='Sales Order Lines']/field[@name='product_id']" position="before">
            <field name="sl_no"/>
        </xpath>
    </field>
</record>

Thanks.

Hi Hiral unfortunately still the error remains the same ... I doubt am i inheriting the right view in my file ? <field name="inherit_id" ref=sale.view_order_form/>

nishad
on 8/7/13, 9:11 AM

Hello, I have updated code apply change and try it. You have inherited correct view. :)

Hiral Patel (hip)
on 8/7/13, 9:24 AM

Sorry still it is not showing the sl_no column in my tree .......?

nishad
on 8/7/13, 9:50 AM

<xpath expr="//page[@string='Order Lines']/field[@name='order_line']/tree[@string='Sales Order Lines']/field[@name='product_id']" position="before"> try this.

Hiral Patel (hip)
on 8/7/13, 9:58 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: 8/7/13, 6:24 AM
Seen: 2672 times
Last updated: 3/16/15, 8:10 AM