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

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)]}}
形象
丢弃
相关帖文 回复 查看 活动
1
6月 22
5506
2
11月 23
1637
1
9月 23
1753
1
3月 22
2880
1
2月 22
5506