Skip to Content
Menu
This question has been flagged
4 Replies
9355 Views

In my Sale Order Lines when I choose a product, the name is defined as [Internal Reference of the product] + product name.

I would like just to keep the product name.

Avatar
Discard
Best Answer

FTR: There is a OCA module for that.

 www.odoo-community.org/shop/product/remove-product-code-from-sale-order-line-name-5402

It should work for v11, v12, for v13, v14 just remove @api.multi

Avatar
Discard
Best Answer

You can make a custom module with a class that inherits from "product.product", and override the name_get() function. I do that for analytic accounts, since I don't like having the full hierarchy in the name. However, looking at the name_get() of product_product in product/product.py, it looks like there's a built-in context option to turn that off:

code = context.get('display_default_code', True) and d.get('default_code',False) or False

if code:

    name = '[%s] %s' % (code,name)

So you could override name_get for this class to change it globally, but if you want a simpler solution on a page-by-page basis, you can just create custom views to turn the full name off. For example, to change the view in sale/sale_view.xml, you'd make a custom module with this xml file in it:

<?xml version="1.0"?>
<openerp>
<data>

    <record id="my_custom_sale_view" model="ir.ui.view">
        <field name="name">my.sale.order.form</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="attributes">
               <attribute name="context">{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom,'display_default_code':False}</attribute>
            </field>

        </field>

    </record>

</data>
</openerp>

 

The original product_id field (in sale_view.xml) is buried in some layers of xml tags, so you might have to use xpath to target it correctly, but that's the general idea. If you pass that variable in the context for the product_id field, it should leave out the internal reference ID in the display name.

Avatar
Discard

Hi, can you specify how to override the function..?

I using Odoo13.

Best Answer

Yes, please. I have the same issue. I am also using Odoo 13

Avatar
Discard