1
我有两个字段,如下所示。连接日期和时间odoo 9.0
> appo_date = fields.Date(string="Appointment Date")
> appo_time = fields.Float(string="Appointment Time")
我需要连接这两个字段。为此,我写了一个函数,如下所示。
def _combine(self, cr, uid, ids, field_name, args, context=None):
values = {}
for id in ids:
rec = self.browse(cr, uid, [id], context=context)[0]
values[id] = {}
values[id] = '%f - %f' % (rec.appo_date, rec.appo_time)
return values
然后在单独的字段中调用该函数,如下所示。
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"/>
我得到一个错误
TypeError: _combine() takes at least 6 arguments (5 given)
谢谢你..但我已经DATE_FIELD(appo_date = fields.Date(字符串=“预约时间”))我应该提供什么数据类型来获取日期 –
日期数据类型是工作正常。它会提示用户输入日期。 –
是的,谢谢你Odedra ..它的作品 –