Odoo Help


ids parameter in write ORM function help.

Lakay lakay
on 9/15/14, 12:20 AM 1,844 views


i have a function here:

def btnSet(self,cr,uid,ids,values,context=None):

                return True

I know that ids is the id record , for example self.write(cr,uid,[1],{'current':'true'}) 

[1] -> for one only.      [1,2,3]-> for multiple record   [???] -> for all, (just with the same uid, not all record with varying uid)


record 1's current field will be set to 'true'   what if i want all record for that certain uid? (its like changing all the values of 'current' field to true.







| 5 4 7
Bikaner, India

OpenERP Developer at SunARC Technology

On 9/15/14, 12:52 AM

uid - Current User Login ID so it shows all the record same ID.

using write method below code to update single record:-


using write method below code to update multile record:-

for id in ids:


search_ids = self.search(cr, uid, [('create_uid','=',uid)])
 if search_ids:
      for id in search_ids:

Sorry, i dont get it.. sorry for my foolishness .. could you help me understand what if its like this for example my records are: id create_uid addr write_uid current 3 5 SG 1 f 4 5 PH 1 f 5 1 PH1 5 t 1 5 PH2 5 t for example i logged as # 5, ofcourse all create_uid with #5 will be shown and if i want to modify (fields with id 3,4,1) their 'current' fields i will just self.write(cr,uid,[3,4,1],{'current':'true'}) its just like hardcoding. what if i want "all" which has contain_id of '5' to be all 'f' what would i change?

Lakay lakay
on 9/15/14, 1:57 AM

I'm not sure I follow you. Based on your requirement search the records based on condition it return search record ids and update the records.

on 9/15/14, 2:14 AM

your editted code works, search_ids = self.search(cr, uid, [('create_uid','=',uid)]) if search_ids: for id in search_ids: self.write(cr,uid,[id],{'current':False}) this is what iwanted can you explain the flow please,

Lakay lakay
on 9/15/14, 2:48 AM

using ORM search method based on condition it return matched condition LIst of record ids. And after using search List of ids update the record using write method.

on 9/15/14, 2:56 AM

why you replace [ids] with [('create_uid','=',uid)] can you explain ? thx

Lakay lakay
on 9/15/14, 3:07 AM

see the link https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/methods/ Expressing a search domain (args) Each tuple in the search domain needs to have 3 elements, in the form: ('field_name', 'operator', value)

on 9/15/14, 3:26 AM

thank you so much prakash!

Lakay lakay
on 9/15/14, 4:02 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/15/14, 12:20 AM
Seen: 1844 times
Last updated: 3/16/15, 8:10 AM