Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
8 ตอบกลับ
244 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

will print the ids of the record.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

What about the active_id???


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน

Thanks for the answer but it doesnt work :/

คำตอบที่ดีที่สุด

May be this will help you.

var[0].project 

or

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

    print var.project

อวตาร
ละทิ้ง
ผู้เขียน

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 :/

ผู้เขียน

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 25
1430
0
ม.ค. 25
3526
1
ส.ค. 23
14878
change password แก้ไขแล้ว
1
ส.ค. 23
13541
1
ก.ค. 23
10516