Normally when editing a model in Odoo, one can click the Discard button to revert all changes.
Now I have a button that performs some modifications on the model, for example it clears a field. Sadly this change is not reverted when clicking Discard. So I assume that the change I make to the model in code is directly persisted. How do I modify a model in a way, that the change is not directly persisted before clicking Save?
In other frameworks one often modifies a working-copy of a model, which can simply be discarded or applied to the real model. How does the Discard mechanism in Odoo work?
Example
In my view I have a button:
<header>
<button string="Clear Filter" type="object" name="clear_filter"/>
</header>
And in my model I clear the filter like so:
def clear_filter(self):
for record in self:
record.filter = None
This works, but the modification of the field is directly persisted and cannot be discarded.