Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
7240 Visninger

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
Kassér
Bedste svar

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
Kassér
Bedste svar

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
Kassér
Related Posts Besvarelser Visninger Aktivitet
3
aug. 24
13521
1
jun. 25
15211
3
apr. 25
5323
2
jul. 24
2208
1
jan. 24
1698