跳至内容
菜单
此问题已终结
1 回复
2265 查看

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


形象
丢弃
相关帖文 回复 查看 活动
6
3月 24
21446
4
7月 25
35006
0
11月 16
2425
1
5月 18
6001
0
12月 24
923