I've simplified my code for the sake of this question, but basically I have this
class Booking(models.Model):
_name = 'ff.booking'
boat_ride_bookings = fields.Many2many('ff.boat_ride_booking')
foo = fields.Integer()
class BoatRideBooking(models.Model):
_name = 'ff.boat_ride_booking'
booking = fields.Many2many('ff.booking')
foo = fields.Integer()
In another place (outside of both of these models) I'm trying to do create some BoatRideBooking objects on existing Booking objects and then connecting them.
This works
# booking is a referance to an existing record
brb = self.env['ff.boat_ride_booking'].create({ 'foo': 1 })
booking.boat_ride_bookings = [(4,brb.id)]
But I want to do something like this
# booking is a referance to an existing record
brb = self.env['ff.boat_ride_booking'].create({ 'foo': 1, 'booking': booking.id })
or even better
# booking is a referance to an existing record
booking.boat_ride_bookings = [(0,0,{ 'foo': 1, 'booking': booking.id }]
but that neither works. I probably don't have the right syntax and I've been looking everywhere and trying a lot.
Someone know the right syntax on how to solve this problem?
Thanks!