Ir al contenido
Menú
Se marcó esta pregunta

Is there a function that can be used to get and check the data every time a specified menu is loaded/opened?

I have 1 field in the appointment module (time). What I want is when I open the appointment menu, a function will try to get/check all the data in appointment, then later the time field will be filled in according to the code I have made. So every time I open the appointments menu, odoo will check the existing data, and the time field data can be updated.


@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(MyMenu, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
data = self.env['appointment.appointment'].search([])
for record in data:
 app = self.env['appointment.time'].search([('time1','<=',record.time),('time2','>=',record.time)], limit=1)
if duration:
record.time_final= app.name + "o'clock"
return res


I have tried the code above, but it only runs 1 time (when I restarted the odoo server).

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 19
8600
1
abr 15
4844
0
mar 15
3363
3
ago 24
1728
1
ago 22
7892