コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2237 ビュー

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
21403
4
7月 25
34979
0
11月 16
2421
1
5月 18
5970
0
12月 24
898