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

Please who can help

I work with odoo v8

i want to get the id of an attribute.

I made

var = self.browse(cr, uid, ids, context)

print var.project

but i got False

who knows the answer please

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

var = self.search(cr, uid, ids, context)

will print the ids of the record.

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

if the ids is a list of ids then you have to write

var = self.browse(cr, uid, ids[0], context)

if ids is just a number representing an id of a record in the table related to the class, the id field, then this expression should work

As per your comment " i want to get the id of a current view which is not saved yet. "  I think you're working within the create method, in this case you have to call :

new_id = super(your_class,self).create(cr,uid,ids,context=context)

you can then use this new_id in your expression

var = self.browse(cr, uid, new_id, context)

print var.project

and it will work

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

What about the active_id???


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

var = self.browse(cr, uid, ids[0], context)
print var.project

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

Thanks for the answer but it doesnt work :/

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

May be this will help you.

var[0].project 

or

for var in self.browse(cr, uid, ids, context) :

    print var.project

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

Thanks for your answer. But it doesnt work. Look please i want to get the id of a current view which is not saved yet. But i didnt find any solution when i make print i got False :/

Tác giả

Please do you know how to call the result of a function to be used in an other function??

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 25
1440
0
thg 1 25
3569
1
thg 8 23
14919
change password Đã xử lý
1
thg 8 23
13583
1
thg 7 23
10549