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

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?



Ảnh đại diện
Huỷ bỏ
Tác giả

@Bella James, thanks, it works.

Câu trả lời hay nhất

Hi 

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


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

Regards


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
6
thg 3 24
21442
4
thg 7 25
35002
0
thg 11 16
2424
1
thg 5 18
5992
0
thg 12 24
921