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

hi! all, i have two class one is patient and second is doctor. and i have to create many2one fields in both side to relate each other. now i want when patient class many2one fields is selected  a doctor record then automatically that patient record id or name is filled in doctor class many2one fields in tree view and only read-only.

Avatar
Discard
Best Answer

Here is what you probably want:

1. A one2many field in doctor. You don't want to have a many2many record for each doctor record pointing to all its patients. That is inneficcient. You just need to retrive all patients that reference this doctor. That is what a one2many field does.

2. To automatically fill in information about a doctor what you need is:

    1. A related field

    2. Mark fields as readonly in the python source code


Read about related fields here:

https://www.odoo.com/documentation/11.0/reference/orm.html#related-fields

The whole document itself is really good. It also talks about one2many fields.

Avatar
Discard