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.

1

Show product default code in account invoice line

By
Jihen BEN ALI
on 7/16/15, 6:57 AM 775 views

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

Thank you

0

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

0
Jihen BEN ALI
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):

_name='product.product'

_inherit='product.product'

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

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

1 follower(s)

Stats

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