Community mailing list archives

Re: how to set a unique default value for new fields

Stefan Rijnhart
- 03/24/2016 04:57:20
On 03/24/2016 09:32 AM, pedro cachaca wrote:

But when I update the module, all existing records get the same value uuid for token...

Hi Pedro,

as you found out, when a new field is added to the Odoo datamodel, and it has a default method, this method is only called once and the result is applied to all existing records. Afterwards, the method is called for every new record that is being created.

You need to write a post_init_hook to generate distinct tokens for existing records.


Opener B.V. - Business solutions driven by open source collaboration

Stefan Rijnhart - Consultant/developer

tel: +31 (0) 20 3090 139