跳至內容
選單
此問題已被標幟
2 回覆
7246 瀏覽次數

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

頭像
捨棄
最佳答案

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')

頭像
捨棄
最佳答案

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.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
3
8月 24
13534
1
6月 25
15224
3
4月 25
5341
2
7月 24
2231
1
1月 24
1707