Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
3745 Представления

I have two fields Start Time and End Time i need to display these two fields in one fields

For Eg:

Start Time: 08:00
End Time: 11:00
I need output like this:
Start End Time: 08:00 - 11:00

Can we merge this two fields in one field?


Thanks in advance

Аватар
Отменить
Лучший ответ

Hi,

You can achieve this by using Computed fields with type Char.

fields.Char(compute='_compute_time',string='Start-End Time')

And in function get values from that two field and join it like you want.


Hope this helps.

Аватар
Отменить
Автор

Thanks

Автор Лучший ответ

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] = '%s - %s' % (rec.start_time, rec.end_time)
return values 

'start_end_time': fields.function(_combine, string='Start End Time!', type='char',
arg=('start_time','end_time'), method=True),

Got solution

Thanks

Аватар
Отменить