1
这是我的代码:为什么我得到这个错误类型错误:strptime()参数1必须是字符串,而不是bool的
@api.onchange('birth_date','age','a')
@api.one
def update_ages_onchange(self):
if self.birth_date < (datetime.now() - timedelta(days=(180))).strftime('%Y-%m-%d'):
d1 = datetime.strptime(self.birth_date, "%Y-%m-%d").date()
d2 = date.today()
self.age = relativedelta(d2, d1).days
a = relativedelta(d2, d1)
self.a = ' Less than' str(a.days) + ' days'
如何解决这个错误:类型错误:strptime()参数1必须是字符串,而不是。BOOL,在D1 = datetime.strptime(self.birth_date, “%Y-%间%d”)日期()
这个错误发生,因为字段为空和空odoo值转换为false,只是检查,如果你使用它之前的字段值 – Cherif