Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
3809 Visualizações

Image Preview

what i want to do in my custom form that is on image preview ...
what i have done .....

in Py

tz = fields.Selection('_tz_get', string='Timezone', required=True, default=lambda self: self.env.user.tz or 'UTC')

in XML

<field name="tz"/>​


Error is 

object has no attribute '_tz_get'

any solution please

Avatar
Cancelar
Melhor resposta

Hello, 

Try this maybe it should work.

import pytz

date_tz = fields.Selection('_tz_get', string='Timezone', required=True, default=lambda self: self.env.user.tz or 'UTC')

@api.model
def _tz_get(self):
return [(x, x) for x in pytz.all_timezones]




Avatar
Cancelar
Melhor resposta

Hello,

the definition of 'tz_get' is missing:

you must add in py file

import pytz
@api.model
def _tz_get(self):
return [(x, x) for x in pytz.all_timezones]
Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
2
abr. 23
3258
2
fev. 21
16418
1
out. 20
3478
0
set. 16
4403
1
abr. 16
6742