Skip to Content
Menu
This question has been flagged

hello all i'am workig on leaves conditions module in version 10 , i added a validation that rais when no joining date asigneed to the employee , it;s working well,

but it's also raise while requesting allocation by employee tag , although i am tried a tag with only one employee in this tag and i am assigned a joining date for him

here is the code 

@api.constrains('state', 'date_from', 'holiday_status_id',)
def _check_hire_date(self):

if self.employee_id.joining_date:
jo_dt = fields.Datetime.from_string(self.employee_id.joining_date)
else:
raise ValidationError("you must define joining date")

Avatar
Discard
Best Answer

Hi Mohamed,

If you don't want to raise constraint at allocation time,


@api.constrains('state', 'date_from', 'holiday_status_id',)
def _check_hire_date(self):
    if self.type == 'remove':                          
    if self.employee_id.joining_date:
    jo_dt = fields.Datetime.from_string(self.employee_id.joining_date)
    else:
    raise ValidationError("you must define joining date")

Use above code.

Thanks,

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 22
1436
1
Jan 23
1074
2
Oct 19
3398
1
Mar 15
3102
1
Jan 24
702