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

Hey guys! 

My code sums up the number of certain products (in the Contact module). In the Form View everything is simply summed up by record. 

For example, in Contact A I have 20 apples and 20 bananas. I therefore have 40 fruits. 

In contact B I have 100 apples and 500 bananas, so I have 600 fruits.


My problem is that in the Tree View all fruits of all contacts are added up - i.e. in the Tree View there are 640 fruits for contact A and 640 fruits for contact B.


@api.depends('fruits_in_use_ids')

    def _compute_sum_used_fruits(self):

        sum_fruits = 0

        for amount in self.fruits_in_use_ids:

            sum_fruits += amount.fruits_amount

        self.sum_fruits_in_use = sum_fruits


I wish you a pleasant Sunday!

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 23
2981
Odoo Column is not showing แก้ไขแล้ว
2
ก.ย. 20
3554
2
พ.ค. 20
3267
Remove sum when GroupBy (online) แก้ไขแล้ว
2
มี.ค. 23
2714
2
ก.ย. 21
8685