Fijar filtro en listview desde la definición de vista xml

En la vista de citas en gnuhealth (Salud-Citas-Calendario), se necesita que el usuario médico al conectarse vea solo los pacientes que el atenderá, pero actualmente se ven todos los pacientes de todos los médicos. Necesito ayuda respecto a como implementar esta característica: filtrar la visualización de registros dinamicamente basándose en el usuario que se conecta.
Agradeceré cualquier aporte al respecto o indicación de algún modulo donde se implementa esta característica y me sirva como ejemplo.
Saludos,
Fernando S.

Hola Fernando,

In this case you have severall options

  1. Add a default search value for the action. With this option the user will be able to remove the filter and search for other user appointments.

  2. Add a domain for the action. With this option records that not match the domain won’t be shown to the user in this acction, but it will be possible to see them on other actions.

  3. Add a domain rule for the model. With this option records that not match the domain won’t be shown to the user in any place of the application and an error message will be shown if the user tries to read them.

You can have a look at our documentation to know more about record rules

Hope it helps!

1 Like

Hola Sergi
Gracias por responder, he probado con domain y con search_value y no logro poner el filtro.


No logro traer del contexto el healthprof y el resultado es;

No se si estoy omitiendo alguna accion, espero le echen una mirada al xml y alguna opinion al respecto.
Saludos
Fernando

The problem is because there is no healthprof key set on the context and then it return the default value (-1).

You should ensure that the helathproft key is set on the context with the correct value.

Estoy revisando la documentación y algún ejemplo dentro de los módulos existentes, para ver la manera de agregar valores al contexto y veo que se usa el método set_context, de la forma: “with Transaction().set_context(key=value)”. Pero, ademas lei que esa asignación es valida solo dentro del bloque “with”. Existe alguna manera de agregar el “key=value” y la asignación quede “persistente” al menos durante la ejecución del modulo?
O en su defecto si alguien puede indicarme en que parte de la definición del modelo o método especifico debo declarar el “with” y este se pueda leer desde el “search_value” o “domain” en el xml del treeview.
Gracias anticipadas por las posibles respuestas.
Saludos
Fernando

You should override the _get_preferences method of res.user model to set the values on every requests of the client of a especific user. In the company module there is an example about how to save the company and the employee

Hope it helps!