跳至內容
選單
此問題已被標幟

Hello everybody, I have a question with the _constraints in Odoo, I have this constraint:

(_check_days_hours, 'No puedes realizar esta solicitud ya que tienes una ausencia en la que has tomado horas y la cantidad de días escogidos es igual o superior a la cantidad de días disponibles en este tipo de ausencia.', ['number_of_days_temp','number_of_hours_temp']) --> This constraint is executed when 'number_of_days_temp' or 'number_of_hours_temp' are changed.


_check_days_hours function:

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

    for record in self.browse(cr, uid, ids, context=context):

        if record.state == 'draft' or record.state == 'confirm':

            if record.employee_id.remaining_hours > 0 and record.employee_id.remaining_leaves == 1:

                aux = 7.5 - record.employee_id.remaining_hours

                if record.number_of_hours_temp > aux:

                    return False

return True



I will give you a example, If the value of  remaining_hours  is 5 and the value of  remaining_leaves is 1 then the value of "aux" is 2.5 and when you try input more of 2.5 in number_of_hours_temp this give a error.


But... sometimes if I get the error several times after if I input the correct value the error appears again, but when I go back in Odoo and I enter to the form again the error disappear.


It's a bug? or I'm doing something wrong? Thanks!


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
6月 23
5346
0
3月 20
3168
2
11月 16
7132
0
3月 15
5322
0
3月 25
1230