Where to put the code when a recod is being saved?

Hello.

Once a record is save, I need to make some changes in several fields. For theses computations, I also need the final ID value.
In which function should I put my code ?
@filelds.depends(“id”) on_change_with_xxx() is not trigged when the id is computed. pre_validate() does not allow any changes…

Thank you for your help.

What kind of computation do you have to do?
What is your use case? The id is a technical field so it does not have any business meaning.

First, I need to generate a sequential, unique ID. Ideally, it would be formated as : YYMM-ID.
I understand that I wouldn’t deal with ID, but i don’t know how to generate a unique ID…

Also, wen the record is modifyed, I also need to perform some updates on chlild records (compare dates and conditionnaly changes status).

You can do that by overriding ModelStorage.create and ModelStorage.write.
For the sequential number, you can use ir.sequence model to generate the ids with the proper configuration (using date etc.).

What about ModelStorage.save: Should this also be a good place for doing such operations?

ModelStorage.save is syntactic sugar that call ModelStorage.create or ModelStorage.write. But there is no guarantee that ModelStorage.save will be called especially because it is not exposed to RPC.