Skip to Content
Menu
This question has been flagged
1 Reply
1228 Views

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?



Avatar
Discard
Author

@Bella James, thanks, it works.

Best Answer

Hi 

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


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

Regards


Avatar
Discard
Related Posts Replies Views Activity
6
Mar 24
19803
4
Apr 23
33122
0
Nov 16
1859
1
May 18
4985
0
Dec 24
30