This question has been flagged
1 Reply
4950 Views

I have a many2one field into "stock.picking", i want to override the name_get so as to get another field, and not the name field of stock.picking, I'm enable to find name_get method for stock_picking so as to override it ? What is the risks of this and how to do it carefully ?

Avatar
Discard
Author Best Answer

First of all, stock.picking did not overrided the name_get method, it uses the name_get of the orm, so I overrided it myself by doing : 

    def name_get(self, cr, uid, ids, context=None):
        if not ids:
            return []
        if context is None: context = {}
        return [(r['id'], (str( r['num_bl']) or '')) for r in self.read(cr, uid, ids, ['num_bl'], context, load='_classic_write')]

where num_bl is the field that you want to replace the name field with.

Knowing that the purpose of it it's change the field to display. There is a lot of overrides, as much as there are a lot of customization with overrides.

Avatar
Discard