Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
1870 Zobrazení

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()

Avatar
Zrušit
Autor

Thanks, it worked

Nejlepší odpověď

Hi Ricky Raymond

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

Thanks.

Avatar
Zrušit
Autor Nejlepší odpověď

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


Avatar
Zrušit

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 Odpovědi Zobrazení Aktivita
4
pro 23
6338
3
čvn 25
973
4
kvě 25
2660
2
kvě 25
6062
1
bře 25
1773