问题描述
我正在使用odoo 12,并且想要将模型中的“日期”字段记录显示到“报告”中,我该怎么做?
仍然面临错误
time data 'False' does not match format '%d %B,%Y'
这是我的代码
@api.multi
def _get_student_dob_in_words(self,student_id):
date_of_birth = fields.Date('BirthDate',default=fields.date.today(),states={'done': [('readonly',True)]})
student = self.env['student.student'].search([('id','=',student_id)])
date_of_birth = student.date_of_birth
# date_of_birth = date.today()
# %Y-%m-%d %H:%M:%s
strp_date = datetime.strptime(str(date_of_birth),"%d %B,%Y")
# dob_result = datetime.strptime(date_of_birth,DEFAULT_SERVER_DATETIME_FORMAT).date()
# str_dob_result = str(date_of_birth)
strp_dob_result = num2words(strp_date)
strp_dob_result = strp_dob_result.upper()
return [{
'dob_in_words': strp_dob_result}]
解决方法
您根本不需要INSERT INTO user_db (month,user_count,percentage,total_percentage)
SELECT
month,user_count/total * 100,user_count/grand_total * 100
FROM old_user_db
WHERE month = '2020-06'
,可以使用strptime
。您仍然必须测试日期是否存在。而且我也将其作为计算字段。
strftime