Community mailing list archives

community@mail.odoo.com

Re: Conditional Unique Constraint

by
vak0160.work
- 08/07/2015 05:16:53
Where should I put the SQL code in my model?

Regards,
Andre

On 08/07/2015 04:14 PM, Alexandre Fayolle wrote:
> On 07/08/2015 10:57, vak0160 wrote:
> > Hello Community,
> >
> > How can I create a unique constraint, but only when /active/ field is
> > /True/?
> >
> Create a partial unique index specifying a where clause, for example:
>
> create unique index on product_product(default_code) where active=true;
>
>
>
> -- 
> Alexandre Fayolle
> Chef de Projet
> Tel : +33 4 58 48 20 30
>
> Camptocamp France SAS
> Savoie Technolac, BP 352
> 73377 Le Bourget du Lac Cedex
> http://www.camptocamp.com
>
> _______________________________________________
> Mailing-List: https://www.odoo.com/groups/community-59
> Post to: mailto:community@mail.odoo.com
> Unsubscribe: https://www.odoo.com/groups?unsubscribe
>