I want to prevent the selected record to show again in the combo box.
As you can see, the 710 - Maleo
show again after I selected that record before.
Field declaration for One2many
field
class RMReservationOrderLine(models.Model):
_name = "rm.reservation.order.line"
_description = "Reservation Order Line"
room_line_ids = fields.One2many('rm.reservation.room.line', 'order_id', string='Rooms')
Model class for One2many
field
class RMReservationRoomLine(models.Model):
_name = "rm.reservation.room.line"
_description = "Reservation Room Line"
order_id = fields.Many2one('rm.reservation.order.line', string='Order', required=True, ondelete='cascade')
room_id = fields.Many2one('rm.room', string='Room', required=True)
UPDATE
Since my model class for the One2many
field just have a single field, room_id
, I just change the One2many
field to Many2many
. Because by default Many2many
field prevent duplicate record.
But I still want to know how to prevent duplicate records if I use the One2many
field, In case I have more than 1 field in the model class for One2many
.