Odoo Help


Show product default code in account invoice line

on 7/16/15, 6:57 AM 1,486 views

How do I show the product default code in the "Product" column and product name in the "Description" column?

Thank you


In which part of the product.py I need to put your piece of code to be functional?

I try to modify the product_id and name field too to show different elements but I can't do it..

To show only the name without the code in Description field, you can do: (product.py line 1017 +/-)

def _name_get(d):

name = d.get('name','')

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

return (d['id'],name)

But because of I can't try your code I don't know if this will overwrite your class or not. It means that I understand that your "Product" column is searchable too. With the change that I tell, this column is searchable and it only shows the product name.

I'll try yo add another field to product changing the python code, but I can't do it too. This change will be to add an extra field that only have the default code apart of the fields 'product_id' and 'name'.

On 7/16/15, 7:56 AM

Hi everyone, I found how to show in th product column the default_code but for the description I still get the default_code + the name any help about this

This is my code:

class snc_product(osv.osv):



def name_get(self, cr, uid, ids, context=None):

return_val = super(snc_product, self).name_get(cr, uid, ids, context=context)

res = []

def _name_get(d):

code = d.get('code','') 

if d.get('variants'):

code = code + ' - %s' % (d['variants'],)

return (d['id'], code)

for product in self.browse(cr, uid, ids, context=context):

res.append((product.id, (product.code)))

return res or return_val

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

1 follower(s)


Asked: 7/16/15, 6:57 AM
Seen: 1486 times
Last updated: 9/14/15, 7:13 AM