It is currently Tue May 22, 2012 11:06 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: How to add a sql_constraint?
PostPosted: Mon May 02, 2011 4:17 pm 
Offline

Joined: Fri Apr 30, 2010 10:35 am
Posts: 90
hello,

how can a sql_constraint be added?

the "OpenERP" sql_constraint is looking for an existing postgres constraint, right?

so, do i have to create the postgres constraint manually in postgress, or is there any way to do it in python code?

thanks


Top
 Profile  
 
 Post subject: Re: How to add a sql_constraint?
PostPosted: Mon May 02, 2011 4:38 pm 
Offline

Joined: Fri Nov 21, 2008 9:56 am
Posts: 3079
Location: Lotharingie
do a module with inheritance (python code), and add your sql constraint :
a little result by searching with menu search at the top of the page :
topic18021.html?hilit=sql_constraint


Top
 Profile  
 
 Post subject: Re: How to add a sql_constraint?
PostPosted: Mon May 02, 2011 4:45 pm 
Offline

Joined: Fri Apr 30, 2010 10:35 am
Posts: 90
thanks for your answer.

i already seached within the forum, but it's not clear to me.

as an example, i would like to add a sql_constaint to my own module:
_sql_constraints = [
('my_key_value', 'UNIQUE (key_value)', 'key value has to be unique !')
]

is my_key_value the name of the postgresql constraint?
if i install the module, i get tuple is not callable and there is no constraint created within postgresql.

can you please help me further?


Top
 Profile  
 
 Post subject: Re: How to add a sql_constraint?
PostPosted: Tue May 03, 2011 9:08 am 
Offline

Joined: Fri Nov 21, 2008 9:56 am
Posts: 3079
Location: Lotharingie
from technical memento :

Code:
_sql_constraints list of tuples defining the SQL constraints, in the form
(name, sql_def, message)


example :
Code:
_sql_constraints = [('name_uniq','unique(name)', 'Idea must be unique!')]


Top
 Profile  
 
 Post subject: Re: How to add a sql_constraint? [SOLVED]
PostPosted: Tue May 03, 2011 12:41 pm 
Offline

Joined: Fri Apr 30, 2010 10:35 am
Posts: 90
thank you very much.

It is working now, i sticked to the naming like 'name_uniq'.


Top
 Profile  
 
 Post subject: Re: How to add a sql_constraint?
PostPosted: Tue May 03, 2011 3:26 pm 
Offline

Joined: Fri Nov 21, 2008 9:56 am
Posts: 3079
Location: Lotharingie
openerp technical memento :
http://www.openerp.com/download/OpenERP ... v0.6.3.pdf


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP