Odoo Help

0

Product's Internal Reference [Closed]

By
Sergii Kauk
on 5/6/13, 10:47 AM 6,474 views

The Question has been closed for reason: duplicate question

by
Sudhir Arya (SA)
on 05/06/2013 11:09:45

I'd like to remove product reference from the product description so instead something like this:

[AB0123] Sample product

I have just "Sample product". Cannot find the way to customize this easily. Can someone give a tip?

2
Ghanshyam Prajapati
On 5/6/13, 11:29 AM

You need to overwrite name_get function of product.product object.

Here is example,

class product_product(osv.osv):
    _inherit = 'product.product'

    def name_get(self, cr, uid, ids, context=None):
        return_val = super(product_product, self).name_get(cr, uid, ids, context=context)
        res = []
        def _name_get(d):
            name = d.get('name','')
            if d.get('variants'):
                name = name + ' - %s' % (d['variants'],)
            return (d['id'], name)
        for product in self.browse(cr, uid, ids, context=context):
            res.append((product.id, (product.name)))
        return res or return_val

product_product()

You have to make one customize module, and install it in your database. if you want to make change in directly product.py then you must do following changes in product.py of product module. replace following code

def _name_get(d):
    name = d.get('name','')
    code = d.get('default_code',False)
    if code:
        name = '[%s] %s' % (code,name)
    if d.get('variants'):
        name = name + ' - %s' % (d['variants'],)
    return (d['id'], name)

with

def _name_get(d):
    name = d.get('name','')
    if d.get('variants'):
        name = name + ' - %s' % (d['variants'],)
    return (d['id'], name)

Thanks! Where do I put this piece of code?

Sergii Kauk
on 5/6/13, 11:38 AM

r u new in Openerp..?? you must put this code in your customized module. hav u created customize module..??

Ghanshyam Prajapati
on 5/6/13, 11:43 AM

Yes, I'm new. For now I've modified product.py file but I realize this isn't sustainable. By the way, name_get method I have there is a little bit more complex than the one you've quoted.

Sergii Kauk
on 5/6/13, 11:56 AM

No you have to make one customize module, and install it in your database. if you want to change in product.py then you must do following changes.

Ghanshyam Prajapati
on 5/6/13, 12:01 PM
0

You need to override name_get method of product.product by removing 'code' from there. Just keep 'name' as you said.

0
Keyur
On 5/6/13, 11:01 AM

You need to overwrite name_get function of product object. There you can add your changes. Have a look at name_get method of ORM.

What would be the best way to make this change so the code doesn't get overwritten during the update?

Sergii Kauk
on 5/6/13, 11:33 AM
0
Gustavo
On 5/6/13, 11:01 AM

You need to modify the view that shows both columns. In order to do that, you need to create a module that inherits the view, and then modify the columns according to your requirements.

0

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.

Register

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

2 follower(s)

Stats

Asked: 5/6/13, 10:47 AM
Seen: 6474 times
Last updated: 3/16/15, 8:10 AM