Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3310 มุมมอง

Hi.

I would really appreciate if someone could give me a guide. 

I have 2 models:

  • Doctors

  • Patients

In the view where I create the patients, I add a Many2Many field with the Doctors model.

The main idea is to link a patient with as many doctors as I want.

Then, add in the Sale Order view  the following Many2one fields:


- Patient

- Doctors


What would you like?

Doctor field should only show those doctors that are already linked to the patient.


What happens right now?

The Doctor field shows all the doctors that are created. 


Thank you!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

For this, you will have to write an onchange method to set the domain to filter the doctors based on the selected patient.

You can write the following type of onchange:

@api.onchange('patient_id')
def onchange_patient(self):
return {'domain': {'doctor_ids': [('id', 'in', self.patient_id.doctor_ids.ids)]}}
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to get Many2many records ids แก้ไขแล้ว
1
มิ.ย. 22
5561
2
พ.ย. 23
1658
1
ก.ย. 23
1783
1
มี.ค. 22
2928
1
ก.พ. 22
5551