Skip to Content
Menu
This question has been flagged
3450 Views

Hi.  I'm having difficulties in creating a flow on Odoo, and maybe you could show me the proper way.

I have the following situation: Odoo v11

Considering a doctor (res.partner) can have many appointment slots (clin.appointment_slot). Each appointment slot is a specific time in a day of the week he will receive patients. So `clin.appointment_slot` has:

- doctor_id (fk to res.partner)

- weekday (integer)

- hour (float)

So when scheduling a appointment, the operator should inform the doctor, and the desired date, and the system would show which appointment slots are available (by showing appointment slots for the day of the week). It should also filter out, or at least tag slots that are not available (because there is already another appointment scheduled for that day/hour/doctor).

Currently I have a form view for the `clin.scheduling` class, where appointments would be make.

I added a `appointment slots` field to `clin.scheduling` (a many2one to `clin. appointment_slot`), with `store=False`, and tried to use `api.onchange` on `doctor` and `date` to get the available slots and populate ` appointment_slots`.

It didn't work, as `appointment_slots` was showing all objects in the database, and my code did no changes.

I also tried to set `appointment_slots` as a selection field, and change that selection, but eventually found out it would not work because the selections can't be changed in this way.

I'm currently trying to use domains on the form xml to filter the appointment slots, but I'm having trouble creating the filter involving "not existing another object for this same time". Also I have to get the week day from the selected date and feed it into the domain, but I don't know if there's a way to do it (or if it's the right way to do it).

Am I trying to solve this in the correct way, or does Odoo have a better way handle this situation?


Avatar
Discard