Community mailing list archives

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

Ondrej Kuznik
- 03/24/2016 07:52:24
On 24/03/16 11:23, pedro cachaca wrote:
> Hi Stefan and Ondrej,
> I am trying  with "post_init_hook" on Odoo 8 without success,
> I follow this example
> :
> Is "post_init_hook" executed only at installation or -i ? or is
> *available for module update -u ?*
> Ondrej, is _set_default_value_on_column another way to do ? not easy to
> find example...

Hi Pedro,
default function and _set_default_value_on_column are only called when
the column does not exist yet. If you have already tried loading the
module, upgrading it will not trigger it again. So long as you are
developing your module on a test system, just drop the column and
upgrade the module.

As far as I am aware, there are no decent public examples of this
function being used. There was one in an earlier pull request of ours:


credativ Ltd
Suite 5, Bloxam Court
Corporation Street           UK office:  +44 1788 298150
Rugby                        Email:
CV21 2DU                     Web:

We would love to hear you your feedback on the service provided. If
you have anything you would like to contact us on the service we have
provided, please send your feedback to

credativ Ltd is registered in England & Wales, company no. 5261743
Certified by CompTIA / AccredIT UK with the ICT Supply standard of
quality for Software Product Design and Development