Skip to Content
Menu
This question has been flagged

Hello everybody!!!!

Please, i have a class that contains an employee_id field.

So for the different records of my class, i want to block those with the same employee_id.

I have tried to work with sql_constraint but it doesnt work well.

Here is my code.

('uniq_name', 'unique(employee_id)', "A stuff already exists with this name . Stuff's name must be unique!"),

]

def on_change_test_id(self, cr, uid, ids, employee_id, context=None):

obj = self.pool.get('solde.compte')
obj_ids = obj.search(cr, uid, [('employee_id', '=',employee_id)])
vals = obj.read(cr,uid,obj_ids,['id','employee_id'],context=context)
if vals == []:
res = {'value':{'remaining_leave': self.get_inputs(cr, uid, ids, employee_id, context=context),
}
}
return res
else:
My_error_Msg = 'Attention!! Vous avez deja rempli un SOLDE DE TOUT COMPTE de cet employe'
raise osv.except_osv(_("Error!"), _(My_error_Msg))
return False

Thanks a lot in advance.

Best Regards.

Avatar
Discard
Related Posts Replies Views Activity
6
Dec 23
63658
1
Mar 19
8916
2
May 15
4532
2
Jun 18
5027
0
Feb 16
4