With following piece of code, what I want to achieve is that if patient is added in a appointment_ids then it should automatically get assigned/computed in respective doctor_id and vice versa means if doctor_id gets changed or set to False then it automatically gets deleted from appointment_ids.
class DoctorAppointments(models.Model): _name = 'doctor.appointments' _description = 'Doctor's Appointments Info' doc_name = fields.Char('Doctor Name') appointment_ids = fields.Many2many('patient.patient')
class Patients(models.Model): _name = 'patient.patient' _description = 'Patient's Info' patient_name = fields.Char('Patient Name') doctor_id = fields.Many2one('patient.appointments', string='Patient Appointment')