Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
8948 Ansichten

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

Avatar
Verwerfen

Sale Order Serial Numbers & Product Images | Auto Numbering & Custom Images in Reports in Odoo
This Odoo module automatically assigns serial numbers to sale order lines and displays product images in reports. If a serial number is manually set to a custom string (e.g., "A"), the next item resets numbering to 1. Additionally, if a product has no image, you can manually upload a custom image for the sale order line—without affecting the original product image.
https://apps.odoo.com/apps/modules/18.0/mh_display_serial_number_and_image

Beste Antwort

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>
Avatar
Verwerfen
Autor

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

Can you try my edit ?

Autor

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..

Autor

"correct 1"

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.

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

Beste Antwort

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.

Avatar
Verwerfen
Autor

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/>

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

Autor

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

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

Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Feb. 20
1
4
Juli 18
17441
2
Jan. 16
8376
0
Okt. 24
3383
2
März 15
5643