Odoo Help

0

Adding SQL constrained by python

By
mehdi
on 3/19/15, 7:04 AM 601 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')]

2

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
3148
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 3/19/15, 8:39 AM

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')]

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 3/19/15, 7:04 AM
Seen: 601 times
Last updated: 3/19/15, 5:15 PM