Skip to Content
Menu
This question has been flagged
3193 Views

I try to extend an existing model (calendar.event) with an new field "category" with required = True.

The addon can be installed on new databases without any problem and also the SQL constraint (NOT NULL) is successfully set for new Databases.

The Problem is that for databases with existing data the new field would need a default value for all of the existing data records or it could not set the SQL constraint and it will throw an error when installed. I really do not want to use a default value for this new field because the user should correctly enter a value!

Is there a way to set a value for all existing records in the database, so that installation would work, but no default value for added fields with required=True ?

Avatar
Discard

Already answered here: https://www.odoo.com/forum/help-1/question/is-there-a-way-to-set-a-value-for-a-field-for-all-existing-records-in-the-database-at-addon-installation-only-89400