Skip to Content
Menu
This question has been flagged
1 Reply
680 Views

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')
Avatar
Discard
Best Answer

Hi,

Try use the relational field for this purpose.

https://www.cybrosys.com/blog/relational-fields-in-odoo

refer the ondelete attribute mentioned in the blog

Regards

Avatar
Discard