跳至內容
選單
此問題已被標幟
1 回覆
3952 瀏覽次數

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")

頭像
捨棄
最佳答案

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,

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
11月 22
2306
1
1月 23
2332
2
10月 19
4533
1
3月 15
4256
1
1月 24
2311