Contributors mailing list archives
contributors@odoo-community.org
Browse archives
Re: Problem with computed default values
by
Camptocamp SA, Simone Orsi
Hi,
yes, the fact is that the default is calculated once per-model instead
of per-instance.
I'm happy I'm not the only one to consider this insane :)
Anyway, a possible workaround is to use `@api.onchange` because this
is triggered even when the form gets loaded the 1st time.
HTH,
S.
On Mon, Apr 11, 2016 at 5:08 PM, Daniel Reis <dgreis@sapo.pt> wrote:
> Hello all,
>
> I'm in need of some expert help.
>
> I added a field to a model, to be used as a random unique identifier:
> token = fields.Char('Token', default=lambda s: str(uuid.uuid4()))
>
> The problem is that, the already existing records all got the same exact
> uuid.
> It seems that the lambda is evaluated once, before a mass update,
> instead of per record, as I expected.
>
> Am I missing something?
> Thanks for any help.
>
> --
> Daniel Reis
>
>
>
>
>
>
> _______________________________________________
> Mailing-List: http://odoo-community.org/groups/contributors-15
> Post to: mailto:contributors@odoo-community.org
> Unsubscribe: http://odoo-community.org/groups?unsubscribe
Reference
-
Problem with computed default values
byClosingAp Open Source Integrators Europe, LDA., Daniel Reis- 11/04/2016 16:59:16 - 0-
-
Re: Problem with computed default values
byClosingAp Open Source Integrators Europe, LDA., Daniel Reis- 11/04/2016 19:04:35 - 0 -
Re: Problem with computed default values
byClosingAp Open Source Integrators Europe, LDA., Daniel Reis- 11/04/2016 18:54:13 - 0 -
-
Re: Problem with computed default values
byClosingAp Open Source Integrators Europe, LDA., Daniel Reis- 11/04/2016 17:29:11 - 0 -
-
Re: Problem with computed default values
byTecnativa. S. L., Pedro M. Baeza- 11/04/2016 17:22:26 - 0 -
Re: Problem with computed default values
byGroupement Régional Alimentaire de Proximité, Sylvain LE GAL- 11/04/2016 17:17:45 - 0 -
-