Daily updates from Odoo
Tuesday, November 15, 2022
1 change
Code cleanup and technical improvements
This change adds standard before-save and after-save hooks so custom actions only run when a record is actually saved successfully. It reduces cases where follow-up actions happen despite validation errors or failed saves, improving reliability across mobile, rental, IoT, planning, quality, and related screens.
Original PR description
The purpose of this commit is to add extension points that allow code
to be executed before and after the save of a record.
CallBack:
onWillSaveRecord is a callBack that will be executed before the
record save. If it returns false, it will prevent the save.
onSavedRecord is a callBack that will be executed after the save
if it was done.
This commit will replace all the save overwrites by the onWillSaveRecord
and onSavedRecord callBack.
Observed problem:
We could notice that each of the overwrites of save in order to execute
for example a doAction after this one did not take into account the fact
that the save did not succeed.
For example, a required field is invalid and we try to save, then the
doAction will be executed without the "write" of the save.
The callBack onSavedRecord will prevent this common error.