i'm using odoo 11 and i received this error RecursionError: maximum recursion depth exceeded in comparison when i added the two fields no_overtime_final and tot_overtime_final .I don't know where is the problem in my method. I notice if i comment these two fields every thing works fine. Any idea for help please ?
class attendance_sheet(models.Model):
_name = 'attendance.sheet'
employee_id = fields.Many2one(comodel_name='hr.employee', string='Employee', required=True)
date_from = fields.Date(string="From", required=True, default=time.strftime('%Y-%m-01'))
date_to = fields.Date(string="To", required=True,
default=str(datetime.now() + relativedelta(months=+1, day=1, days=-1))[:10])
att_sheet_line_ids = fields.One2many(comodel_name='attendance.sheet.line', string='Attendances',readonly=True,
inverse_name='att_sheet_id')
state = fields.Selection([
('draft', 'Draft'),
('confirm', 'Confirmed'),
('done', 'Approved')], default='draft', track_visibility='onchange',
string='Status', required=True, readonly=True, index=True,
help=' * The \'Draft\' status is used when a HR user is creating a new attendance sheet. '
'\n* The \'Confirmed\' status is used when attendance sheet is confirmed by HR user.'
'\n* The \'Approved\' status is used when attendance sheet is accepted by the HR Manager.')
no_overtime = fields.Integer(compute="calculate_att_data", string="No of After work time", readonly=True, store=True)
tot_overtime = fields.Float(compute="calculate_att_data", string="Total After work time", readonly=True, store=True)
no_overtime_final = fields.Integer(compute="calculate_att_data", string="No of Overtime", readonly=True, store=True)
tot_overtime_final = fields.Float(compute="calculate_att_data", string="Total Overtime", readonly=True, store=True)
tot_difftime = fields.Float(compute="calculate_att_data", string="Total Diff time Hours", readonly=True, store=True)
no_difftime = fields.Integer(compute="calculate_att_data", string="No of Diff Times", readonly=True, store=True)
tot_late = fields.Float(compute="calculate_att_data", string="Total Late In", readonly=True, store=True)
no_late = fields.Integer(compute="calculate_att_data", string="No of Lates", readonly=True, store=True)
no_absence = fields.Integer(compute="calculate_att_data", string="No of Absence Days", readonly=True, store=True)
tot_absence = fields.Float(compute="calculate_att_data", string="Total absence Hours", readonly=True, store=True)
att_policy_id = fields.Many2one(comodel_name='hr.attendance.policy', string="Attendance Policy ", required=True)
payslip_id=fields.Many2one(comodel_name='hr.payslip',string='PaySlip')
@api.multi
def calculate_att_data(self):
overtime = 0
no_overtime = 0
overtime_final = 0
no_overtime_final = 0
late = 0
no_late = 0
diff = 0
no_diff = 0
absence_hours = 0
no_absence = 0
for att_sheet in self:
for line in att_sheet.att_sheet_line_ids:
# print line.date
if line.overtime > 0:
overtime += line.overtime
no_overtime = no_overtime + 1
if line.overtime_final > 0:
overtime_final += line.overtime_final
no_overtime_final = no_overtime_final + 1
if line.diff_time > 0:
if line.status == "ab":
no_absence += 1
absence_hours += line.diff_time
else:
diff += line.diff_time
no_diff += 1
if line.late_in > 0:
late += line.late_in
no_late += 1
values = {
'tot_overtime': overtime,
'no_overtime': no_overtime,
'tot_overtime_final': overtime_final,
'no_overtime_final': no_overtime_final,
'tot_difftime': diff,
'no_difftime': no_diff,
'no_absence': no_absence,
'tot_absence': absence_hours,
'tot_late': late,
'no_late': no_late
}
att_sheet.write(values)