Hello, i'm trying to make a work entry through a server action, code is the next:
for rec in record:
inicio = rec.date_start
fin = inicio + datetime.timedelta(days=20)
fechas = []
while inicio <= fin:
if inicio.weekday() in [5, 6]:
fechas.append(inicio)
inicio += datetime.timedelta(days=1)
#raise UserError(fechas)
forms = []
for fecha in fechas:
form = {
'name': 'Entrada',
'employee_id': rec.x_studio_empleado,
'work_entry_type_id': 1,
'date_start': fecha,
'date_stop': (fecha + datetime.timedelta(minutes=120))
}
forms.append(form)
for formi in forms:
record.env['hr.work.entry'].create(formi)
my intention is to create work entry for new employee so i can take in account weekends for payroll
I'm getting the next error:
ValueError: <class 'psycopg2.ProgrammingError'>: "can't adapt type 'hr.employee'" while evaluating
Do you know o have any idea how can i fix this.
appreciate the help in advance, ty