Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
7268 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
srp 24
13547
1
čvn 25
15274
3
dub 25
5397
Compute Fields Vyřešeno
2
čvc 24
2296
1
led 24
1725