def on_models_committed(app, changes):
    for change in changes:
        foo_obj = change[0]
operation = change[1]
if foo_obj.__class__.__name__ == 'Foo':
    if operation == 'insert':
        foo_obj.foo_attr = get_new_value()
db.session.add(foo_obj)
db.session.commit()
models_committed.connect(on_models_committed)
Change object's attribute on session commit - Flask SQLAlchemy