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

hello all,

Here i want to know how to get the first record of a table.

here is my code, please correct it....

    user_ids = self.pool.get('test.project').browse(cr, uid, ids, context=context)

    user_ids[0]

Thanks in advance...

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

I suggest you use this, the safe construction:

test_obj = self.pool.get('test.project')
user_ids = test_obj.search(cr, uid, [('id','in',ids)], context=context)
if user_ids:
    first_record =  test_obj.browse(cr, uid, user_ids[0], context=context)
    first_ID =  user_ids[0]

UPDATE: Full user_ids list from test.project:

user_ids = test_obj.search(cr, uid, [], context=context)
 

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

Hi, This user_ids doesn't return any ids to browse records!!!

ผู้เขียน

Hi, This user_ids doesn't return any ids to browse records!!!

user_ids empty if... all test.project empty or... if your source ids empty or.... source ids not from test.project. What are your ids?

ผู้เขียน

hi, i i'm searching and browsing from another class function, so there is no source ids from test.project. what i do next? please

If you need a full and complete list of the user_ids from test.project, see UPDATE in my answer

ผู้เขียน

Thanks

Related Posts ตอบกลับ มุมมอง กิจกรรม
How can i browse this m2m record? แก้ไขแล้ว
2
มี.ค. 15
4281
1
ม.ค. 19
4981
0
มี.ค. 15
3695
1
มี.ค. 15
7519
0
ม.ค. 17
6993