In some cases you might want to manage which values get written into the database.
Some examples: Say, I want to save a phone number which always must be in the format 'XX-XXXXXXXX' Or a zip code in the format 'XXXX XX' Or you just may want to strip certain characters like trailing spaces.
The given examples are typically 'char' fields.
Which methods or __init__ parameters of these fields can I use to hook in a sort of pre-processing method?
So I expect something like this:
def preprocess(self, cr, uid, id, name, value, context=None):
value = value.strip()
super(my_field, self).preprocess(cr, uid, id, name, value, context=context)
...
... in _columns:
'column1': fields.char('Phone', size=11, preprocess=preprocess),
}
Another option I thought of was making a function field with its own fnct and fnct_inv, and with a store=True. But I'm not sure how to make this fnct method in such a way that it behaves like a normal field.
Note: I'm interested in field-specific callbacks, not in write() and create() overrides.