Community mailing list archives

community@mail.odoo.com

Re: Conditional Unique Constraint

by
Camptocamp France SAS, Alexandre Fayolle - Camptocamp
- 08/07/2015 05:07:46
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