Odoo Help

0

1
2 Answers
1
Avatar

Mohammad Alhashash

--Mohammad Alhashash--
2103
| 6 5 10
October City, Egypt
--Mohammad Alhashash--

Developer

Mohammad Alhashash
26/3/13 15:10

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.

1 Comment
Clément THOMAS
27/3/13 11:30

Thanks Mohammad

1
Avatar

Andreas Brueckl

--Andreas Brueckl--

5476
| 8 8 9
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
26/3/13 13:47

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.

1 Comment
GLOBAL CREATIVE CONCEPTS TECH CO LTD (iWesabe)
22/3/18 02:30

Awesome !! overriding function name_get is working for me !!

Ask a Question
Keep Informed
1 follower(s)
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