Thursday, July 14, 2022
1 change · master
Code cleanup and technical improvements
This update simplifies how Odoo tracks pending data changes before they are saved, reducing the risk of mismatches or lost updates. It also fixes related issues affecting website visitor handling and CRM access for portal users, improving stability in day-to-day operations.
Original PR description
Merging both the memory of field values and suspended updates has several advantages: - avoid inconsistencies between `cache` and `towrite` - cache updates can be made safer w.r.t. dirty flag…
Merging both the memory of field values and suspended updates has several advantages:
- avoid inconsistencies between `cache` and `towrite`
- cache updates can be made safer w.r.t. dirty flag
However, the dirty flag in cache does not go well with context-dependent fields. When a context-dependent field is dirty in cache, the value to store in the database is accessible through some context values. But when the model is flushed, the context values on the current environment may be different. When this happens, the method `flush_X()` fails to retrieve the data to flush.
The proposed solution is to store the "dirty" value in cache under conventional context values, and to retrieve them under the same conventional context values to flush them. For instance, when storing the value of a binary field, it will be stored once under the context value `context.get('bin_size')`, and a second time under the context value `None`. The flush implementation will then retrieve the value using the context value `None`.
Translated fields are also problematic when a value is put in cache with an environment where `lang=False`, and the value is retrieved with another environment where `lang=None`. This issue is addressed by normalizing the context key `lang` to `None` when the context value is `False`.