Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2331 Vizualizări

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).

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
iul. 19
8601
1
apr. 15
4846
0
mar. 15
3363
3
aug. 24
1730
1
aug. 22
7892