İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
3699 Görünümler

Hi Folks,


I added two fields in my model:

  • x_ticket_duration: float

  • x_ticket_duration_sum: float


I want to be able to enter a floating number into x_ticket_duration. This float should then be added to the value in x_ticket_duration-sum.

Formula:

x_ticket_duration_sum += x_ticket_duration


In odoo I made x_ticket_duration_sum dependent on x_ticket_duration. I checked the box to store both values.
In the compute fields for x_ticket_duration_sum I wrote:

self['x_ticket_duration_sum'] += self['x_ticket_duration']

Now when I go to the view I see both fields and when I edit the record the x_ticket_duration_sum is always the same value as x_ticket_duration. But it never saves the sum. I see the value for x_ticket_duration_sum is saved on the DB but when I edit the record again and enter a new float in x_ticket_duration it just writes this value into x_ticket_duration_sum but it doesn't calculate the sum.
Does anybody know how to achieve this?


Thank you and cheers

 

Avatar
Vazgeç
En İyi Yanıt

Hi,

Can you update the below line as follows and see whether it makes any difference,

self['x_ticket_duration_sum'] += self['x_ticket_duration']

To

self['x_ticket_duration_sum'] = sum(self.env.search([]).mapped('x_ticket_duration'))


Thanks

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Haz 21
2383
2
Eyl 24
2395
2
Ara 22
7211
1
Tem 21
6793
1
Haz 22
3115