Skip to Content
Menu
This question has been flagged
1 Reply
2726 Views

Hi everyone, so it's simple I get an error when adding a simple constraint (IdentationError: unexpected ident) that I added directly into postgres without problem


class fleet_site(osv.Model):

_name = 'fleet.site'

_description = 'Information du site'

_order= 'name asc'

_columns = {

'name': fields.char('Nom', help='Nom du site', required=True),

'vehicle_ids': fields.one2many('fleet.vehicle','site_id','Vehicules')

}

_sql_constraints = [('fleet_site_name_unique','unique(name)', 'Le nom du site existe')]

Avatar
Discard
Best Answer

Hi,

It is indentation error, so check you indentation 'spaces' it should be like:


class fleet_site(osv.Model):

#4 spaces

_name = 'fleet.site'

_description = 'Information du site'

_order= 'name asc'

_columns = {

'name': fields.char('Nom', help='Nom du site', required=True),

'vehicle_ids': fields.one2many('fleet.vehicle','site_id','Vehicules')

}

#4 spaces

_sql_constraints = [('fleet_site_name_unique','unique(name)', 'Le nom du site existe')]

Avatar
Discard
Related Posts Replies Views Activity
2
Jan 23
23763
4
Jun 21
37386
1
Dec 20
1482
1
Apr 18
6451
3
Sep 15
8475