Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5272 Lượt xem

Hi, 

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:
availability.get_sum_reservations_still_av()

How do I do to in the end have availabilities_ids equal to : 
vi.availability(39,40,41,42)

And then just do this: 

   availabilities_ids.get_sum_reservations_still_av()


Is it possible ? 

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

 

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks

You're welcome

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
3674
1
thg 7 15
7806
3
thg 2 23
22285
3
thg 8 16
11046
3
thg 7 16
7904