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

I have this 'on_change' function:


remaining_days = fields.Integer(string='Remaining Days', store=True)


@api.onchange('current_date', 'payment_due_date', 'remaining_days')
def calculate_remaining_days(self):
    if self.current_date and self.payment_due_date:
        start_date = self.current_date
        end_date = self.payment_due_date
        days = (end_date - start_date).days
        self.remaining_days = days


Upon saving the record, the value of remaing_days is automatically converted to zero (0)

What could be possibly wrong?



อวตาร
ละทิ้ง
ผู้เขียน

@Bella James, thanks, it works.

คำตอบที่ดีที่สุด

Hi 

use attribute force_save="1" in view to save the value.


<field name="remaining_days"  force_save="1"/>

Regards


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
6
มี.ค. 24
21433
Limit the number of digits in integer? แก้ไขแล้ว
4
ก.ค. 25
34999
0
พ.ย. 16
2423
increment integer for a field odoov11 แก้ไขแล้ว
1
พ.ค. 18
5986
0
ธ.ค. 24
916