Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
7249 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhấ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')

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhấ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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 8 24
13535
1
thg 6 25
15229
3
thg 4 25
5349
Compute Fields Đã xử lý
2
thg 7 24
2236
1
thg 1 24
1709