wanna ask bout expected singleton error in odoo. even ive fixed it with @api.one, iam still confused bout the error and want to know could i fix it without @api.one ? here is my code with @api.one :
class overtime_details(models.Model):
_name='overtime.overtime_details'
@api.onchange('employee_id')
@api.one
def attd_check(self):
#import pdb;pdb.set_trace()
for attds in self:
if attds.id:
ov = 0.0
attd = self.env['hr.attendance']
signin = attd.search([('name','=',self.overtime_id.start_date),
('employee_id','=', self.employee_id.id), ('action','=','sign_in')])
signout = attd.search([('name','=',self.overtime_id.end_date),
('employee_id','=',self.employee_id.id), ('action','=','sign_out')])
if signin:
if signout:
ov = self.env['overtime.overtime'].calc_overtime(self.overtime_id.start_date, self.overtime_id.end_date)
else:
ov = 0.0
else:
ov = 0.0
self.ovrtm = ov
nik = fields.Char('NIK', size=250, required=True)
overtime_id = fields.Many2one('overtime.overtime', string="Overtime", ondelete='cascade')
job_id = fields.Many2one('hr.job', string="Position")
employee_id = fields.Many2one('hr.employee', "Employee", required=True, select=True)
ovrtm = fields.Float(compute='attd_check', string='Overtime Hour(s)')
here is the traceback and iam using odoo 8:
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\fields.py", line 825, i
n __get__
File "C:\Program Files (x86)\Odoo 8.0\server\.\openerp\models.py", line 5323,
in ensure_one
except_orm: ('ValueError', 'Expected singleton: overtime.overtime_details(2,
3, 4)')
iam a newbie in odoo and python this is my 1st time facing this kind of error, thanks before