İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
7264 Görünümler

Hi,

I need to make a float field(which have a compute function) editable.I have tried writing an inverse function for but cant get a clear idea about writing it.

demo_cost = fields.Float(string='Construction Cost', compute='_compute_demo_cost')
@api.depends('field_a', 'field_b')
def _compute_demo_cost(self):
for line in self:
line.demo_cost = line.field_a * line.field_b

Can anyone suggest me a better method or correct inverse function for making this field editable.

Thanks

Avatar
Vazgeç
En İyi Yanıt

Use the inverse function in the field definition - see documentation

demo_cost = fields.Float(string='Construction Cost ', compute='_compute_demo_cost', inverse='_set_demo_cost')

Avatar
Vazgeç
En İyi Yanıt

Hello, 

Can you please check this link :  https://www.holdenrehg.com/blog/2021-03-01_odoo-inverse-field-guide/ to help out your compute field editable issue.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Ağu 24
13547
1
Haz 25
15264
3
Nis 25
5389
Compute Fields Çözüldü
2
Tem 24
2288
1
Oca 24
1723