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

Hello ! 

I have to synchronize a list of records with a side server. I already have my loadMethod that updates odoo DB working but for now the only way i had to call it is to create a field that compute it. It's ugly and I need a "create record" that calls the method.

How can I do to make the method be called when the view is loaded so i can get rid of my "create record" and my useless "actualize compute field".

If it's not possible, can i, at least, call this method when Odoo server is launched ? (the records are not going to be changed a lot on the side server)

Thank you very much !

Imagine profil
Abandonează
Cel mai bun răspuns

Am not sure whether I follow your requirement,

Incase if you are trying to execute a method before creating a Record, then use "default_get()" method, which will be first method to execute for every New record creation.

Or

If you are trying to execute method when everytime view is loaded, then ensure Compute field is not stored to the database, Which means odoo will compute the value for this field every time you load a view, as the data is not stored. However if the compute field is stored to database, then it will be triggered only at the time of creation or update/writing to that record

Or

If you are trying to execute method, at launch of Odoo server, then use "__init__()" method in your Object to perform your task.



Imagine profil
Abandonează
Autor

I answered you below :)

Cel mai bun răspuns

I had the same problem as you

have you found a solution !!


Imagine profil
Abandonează
Autor Cel mai bun răspuns

Thank you for your answer
I'll try to precise it : I would like to generate a list of record (that doesn't exist in a first place) when the view is loaded.
So i created a method that calls create(vals) in a loop but i don't know how to call this method each time the view is loaded without calling it from an instance of the model.

Thank you again !

Imagine profil
Abandonează

I suppose your requirement could be partly achieved using View Objects.(i.e _auto=False). Please check.

Related Posts Răspunsuri Vizualizări Activitate
2
apr. 24
1257
2
dec. 20
9116
0
mar. 15
3265
5
aug. 23
12404
0
iun. 19
4569