Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
2734 Visualizzazioni

In proyects, in every task i have a "total float field", and i need to sum the totals of tasks and render it in the project view, but only the tasks that are in the stage "To do".

this is my code, but is not working.

@api.depends('tasks.sum_total_cost')
    def todo_sum(self):
        todo = self.env['project.task'].search([('stage_id', '=', 'To Do')])
        for task in todo:
            task.sum_todo= round(sum(task.mapped('sum_total_cost')), 2)
Avatar
Abbandona

What field is ejecuction?

Risposta migliore

You just need to apply the sum after filtering with the correct path.

Try this


@api.depends('tasks.sum_total_cost')
def todo_sum(self):
  todo = self.env['project.task'].search([('stage_id', '=', 'To Do')])
for data in todo:
if data:
self.sum_todo = round(sum(todo.mapped('sum_total_cost')), 2)
Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
nov 22
6289
1
giu 22
8263
1
set 21
3181
0
ago 21
95
0
lug 21
172