Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
1921 Переглядів

I have 2 field that consist :


date_checked (datetime)

checked (boolean)


What i want is if boolean checked then date_checked autofill to field.datetime.now()

Аватар
Відмінити
Автор

Thanks, it worked

Найкраща відповідь

Hi Ricky Raymond

You can use odoo onchange method through achive it this requirement.

Thanks.

Аватар
Відмінити
Автор Найкраща відповідь

Already tried using this on change but not working. Or maybe something wrong in my code


@api.onchange('is_approved')
def _change_date(self):
if self.is_approved = True
self.self.approved_date = fields.Datetime.now()
else:
self.approved_date = None


Аватар
Відмінити

Hi please
in your python if condition is wrong that's why Ricky
there are two way check boolean field true or not you direct use
if self.is_approved: or if self.is_approved == True:

if self.is_approved = True
this is wrong in python syntax

self.self.approved_date = fields.Datetime.now()
in this line only one time use
self.approved_date = fields.Datetime.now()

Related Posts Відповіді Переглядів Дія
4
груд. 23
6414
3
черв. 25
1007
4
трав. 25
2685
2
трав. 25
6116
1
бер. 25
1802