跳至内容
菜单
此问题已终结
2 回复
1859 查看

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

相关帖文 回复 查看 活动
4
12月 23
6334
3
6月 25
973
4
5月 25
2645
2
5月 25
6059
1
3月 25
1761