Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3552 Переглядів

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.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
6
груд. 23
66162
1
бер. 19
10604
2
трав. 15
5533
2
черв. 18
5982
0
лют. 16
4