Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7263 มุมมอง

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ส.ค. 24
13547
1
มิ.ย. 25
15255
3
เม.ย. 25
5384
Compute Fields แก้ไขแล้ว
2
ก.ค. 24
2286
1
ม.ค. 24
1722