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 get "record name" (name_get) from a browse_record?

By
Clément THOMAS
on 3/26/13, 1:04 PM 4,331 views

From a browse_record (and not from the pool with name_get function), how to know it default name ?

for example :

sale_order_line.product_id._default_name (it don't works)

Thanks

1

Mohammad Alhashash

--Mohammad Alhashash--
2075
| 5 5 8
Giza, Egypt
--Mohammad Alhashash--

Developer

Mohammad Alhashash
On 3/26/13, 3:10 PM

You can call any object method directly from a browse_record instance, no need to reach the pool. Method parameters cr, uid and context will be passed automatically. To get the display name for your example:

    sale_order_line.product_id.name_get()[0][1]

Note that name_get returns a list of pairs: [(id,name),...]

If you really need to have the value as a field! you can create a function field that uses name_get() to get the value.

Thanks Mohammad

Clément THOMAS
on 3/27/13, 11:30 AM
0

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 3/26/13, 1:47 PM

The default name of a model can be specified by

  • field name (default),
  • field specified in _rec_name or
  • function name_get

If you want to have a generic way to always get the default name of an object you have to use name_get function. The browse_record does not provide a field like _default_name.

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

0 follower(s)

Stats

Asked: 3/26/13, 1:04 PM
Seen: 4331 times
Last updated: 3/16/15, 8:10 AM