Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2240 Представления

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


Аватар
Отменить
Related Posts Ответы Просмотры Активность
6
мар. 24
21406
4
июл. 25
34983
0
нояб. 16
2421
1
мая 18
5971
0
дек. 24
899