如何安排日期时间格式

How arrange datetime format

我有两个字段,如下所示。

>  appo_date = fields.Date(string="Appointment Date")
>  appo_time = fields.Float(string="Appointment Time")

我连接了两个字段。

@api.multi
    def _combine(self):
        if self.appo_date and self.appo_time:
            self.appo_date_and_time = '%s  %f' % (self.appo_date, self.appo_time)
        elif self.appo_date:
            self.appo_date_and_time = str(self.appo_date)
        elif self.appo_time:
            self.appo_date_and_time = str(self.appo_time)

并在单独的字段中调用该函数,如下所示。

appo_date_and_time = fields.Char(compute='_combine', string='Appointment Date/Time', arg=('appo_date','appo_time'), method=True)

这些字段在 xml 个文件中被调用

<field name="appo_date"/>
<field name="appo_time"/>
<field name="appo_date_and_time"/>

我得到的输出为

'2016-05-19  9.00000'

采用这种格式。我需要它19/05/2016 9:00

怎么做

需要使用字符串对象的split函数

尝试使用此代码。

string_obj_name.split(' ')[0]

详情string split function