跳至内容
菜单
此问题已终结
1 回复
845 查看

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')
形象
丢弃
最佳答案

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

形象
丢弃