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 hide the product internal reference that appears between brackets in the sale order line ?

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

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

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

4 follower(s)

Stats

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