Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
22464 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks Mohammad

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 17
4584
3
thg 11 24
30167
1
thg 4 23
4125
1
thg 12 21
2889
0
thg 12 21
2391