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

How to override name_get method of stock.picking [SOLVED]

By
Yassine TEIMI
on 12/12/14, 6:58 AM 603 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 ?

0
Yassine TEIMI
On 12/12/14, 9:08 AM

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.

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: 12/12/14, 6:58 AM
Seen: 603 times
Last updated: 3/16/15, 8:10 AM