我试图创建一个返回日期时间的函数,但它不起作用。它返回错误代码2:
def _date_(self, cr, uid, ids, fields, arg, context):
x={}
for record in self.browse(cr, uid, ids):
if record.date :
a = datetime.strptime(record.date, "%Y-%m-%d %H:%M:%S")
b = a.strftime("%Y-%m-%d %H:%M:%S")
x[record.id] = b
return x
_columns = {
'date': fields.datetime('Date-Hour of Call', required=True),
'date_': fields.function(_date_, string='date copy'),
此致,
您必须定义列日期,如下所示:
'date_': fields.function(_date_, type='datetime', string='date copy'),
感谢