تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2223 أدوات العرض

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
مارس 24
21394
4
يوليو 25
34960
0
نوفمبر 16
2408
1
مايو 18
5955
0
ديسمبر 24
887