Hello,
I have to models.
class HrClockImport (models.Model):
_name = "hr.clock.import"
_description = "Clock Imported from Machine"
_rec_name = 'employee_id'
# to display as caption in a form
hr_attendance_id = fields.Many2one ('hr.attendance', string = "Attendance")
employee_id = fields.Many2one ('hr.employee', string = 'Employee')
clockdatetime = fields.Datetime (string = "Clock")
class HrAttendance (models.Model):
_inherit = "hr.attendance"
hr_clock_import_ids = fields.One2many ('hr.clock.import', 'hr_attendance_id', string = "Import Clock Line")
Here are my code:
clockinout_dict = {'employee_id': emp3, 'check_in': clock3, 'check_out': clock4}
last_id = hr_attendance.create (clockinout_dict)
#update hr.clock.import:hr_attendance_id with the newly created attendance id
clock_obj = self.env['hr.clock.import'].search([('employee_id', '=', emp3),'|', ('clockdatetime', '=',clock3), ('clockdatetime', '=',clock4)])
if clock_obj:
for clock in clock_obj:
clock.hr_attendance_id = last_id.id <----this does not work!
Thank you for your time to read.
Any help will be greatly appreciated.