Odoo Help


How to hide the product internal reference that appears between brackets in the sale order line ?

Tarik Srhiar
on 8/27/14, 10:13 AM 2,487 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.

Ben Olsen
On 8/27/14, 11:13 AM

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"?>

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





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.

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

4 follower(s)


Asked: 8/27/14, 10:13 AM
Seen: 2487 times
Last updated: 3/16/15, 8:10 AM