Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
369 Vizualizări

So i want to create when stage is set to "Ready to Process" that the following happens:

there is a new line added to the timesheet app i have the following code but keep getting an error:


timesheet = env['account.analytic.line'].create({

    'name' : 'dit is een test',

    'project_id' : x_studio_project,

    'task_id' : x_studio_task,

    'data' : x_studio_datum_startdate,

    'x_studio_char_field_776_1hg0t17l3' : x_studio_starttime,

    'x_studio_char_field_3ou_1hg0t3rg2' : x_studio_stoptime,

   

})


get the following error:

psycopg2.ProgrammingError: can't adapt type 'project.task'



Imagine profil
Abandonează
Cel mai bun răspuns

Hi BTD,

The error psycopg2.ProgrammingError: can't adapt type 'project.task' usually occurs when you are trying to pass an object instead of an integer or other basic data type expected by the field. In this case, it looks like you're passing the whole record set of a project or task, but Odoo expects the ID of the project or task.

To resolve this, you need to ensure that you're passing the IDs of project_id and task_id instead of the recordsets. Here's how you can adjust your code:

timesheet = env['account.analytic.line'].create({
    'name': 'dit is een test',
    'project_id': x_studio_project.id,
    'task_id': x_studio_task.id,
    'date': x_studio_datum_startdate, 
​'x_studio_char_field_776_1hg0t17l3':x_studio_starttime,
    'x_studio_char_field_3ou_1hg0t3rg2':x_studio_stoptime,
})
Imagine profil
Abandonează