Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2793 มุมมอง

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!


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 23
5346
0
มี.ค. 20
3168
2
พ.ย. 16
7128
0
มี.ค. 15
5319
0
มี.ค. 25
1230