Odoo Help


How to create a variable with the format new.record(1,2,3,4,5,6)?

Anabela Damas
on 1/26/16, 12:45 PM 848 views


I'm new on the new api , and I have this code: 

availabilities_ids = []

for test in tests:
    availabilities_ids.append(availability_obj.create({'date_available' : datetime_to_availability,})

But in the end of the function the availabilities_ids is like this : 

[vi.availability(39,), vi.availability(40,), vi.availability(41,), vi.availability(42,)]

And I have to do this : 

for availability in availabilities_ids:

How do I do to in the end have availabilities_ids equal to : 

And then just do this: 


Is it possible ? 


On 1/27/16, 3:56 AM

in order to accomplish your requirement in the new API,  you should define "availabilities_ids" as a recordset, instead of a list...  and then add (using union operator) newly created records to it, so in the end you'll have recordset with all the created records, as you describe in your question. Please change your code to this:

availabilities_ids = self.env['vi.availability']


for test in tests:

availabilities_ids |= availability_obj.create({'date_available' : datetime_to_availability,})

and then the availabilities_ids is a recordset ( like "vi.availability(39,40,41,42)" ). that's it.



Versão Integral, Anabela Damas
on 1/27/16, 4:12 AM

You're welcome

on 1/27/16, 4:30 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: 1/26/16, 12:45 PM
Seen: 848 times
Last updated: 1/27/16, 4:15 AM