Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2790 มุมมอง

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)
อวตาร
ละทิ้ง

What field is ejecuction?

คำตอบที่ดีที่สุด

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)
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Create Journal Entries whit code แก้ไขแล้ว
2
ส.ค. 25
6444
1
มิ.ย. 22
8413
1
ก.ย. 21
3279
0
ส.ค. 21
95
0
ก.ค. 21
172