Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
22473 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

Thanks Mohammad

Najlepsza odpowiedź

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.

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
2
wrz 17
4586
3
lis 24
30168
1
kwi 23
4127
1
gru 21
2890
0
gru 21
2391