Odoo Help

Welcome!

This community 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.

0

Adding SQL constrained by python

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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