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

Product's Internal Reference [Closed]

By
Sergii Kauk
on 5/6/13, 10:47 AM 5,104 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

--Ghanshyam Prajapati--
1377
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
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

Keyur

--Keyur--
1165
| 4 4 8
Ahmedabad, India
--Keyur--

Odoo Expert

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

--Gustavo--
950
| 2 1 4
Buenos Aires, Argentina
--Gustavo--

Python developer, big fan of sailing

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

Priyesh Solanki (pso)

--Priyesh Solanki (pso)--
Tiny ERP Pvt Ltd
http://www.odoo.com
1100
| 2 2 4
--Priyesh Solanki (pso)--
Priyesh Solanki (pso)
On 5/6/13, 11:02 AM

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

0

Naresh Soni (nch)

--Naresh Soni (nch)--
Tiny ERP Pvt Ltd
http://www.odoo.com
1281
| 2 2 4
India
--Naresh Soni (nch)--

Team Lead, Odoo(Formerly OpenERP) Support & OPW

Naresh Soni (nch)
On 5/6/13, 11:04 AM

Hello Ska,

Follow this How to make changes in product description

Thanks,

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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