Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2678 Zobrazení

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
Zrušit

What field is ejecuction?

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
lis 22
6197
1
čvn 22
8212
1
zář 21
3139
0
srp 21
95
0
čvc 21
172