Odoo Help


This community 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.


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 476 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 ? 




| 6 5 7
Tbilisi, Georgia
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 1/26/16, 12:45 PM
Seen: 476 times
Last updated: 1/27/16, 4:15 AM