Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
15620 Vistas

Is the any way to show in a form view a date field, only showing the selected week,

i cannot do it through settings -> Translations -> ....  because is only this field who has to show the week of the year, the other date fields are standard format.

I can achieve the result in the qweb report, like this

t-esc="time.strftime('%W',time.strptime(o.requested_date,'%Y-%m-%d %H:%M:%S'))"

But i cannot do it in form wiew.

Any help.


Thanls in advance.

Kind regards.





Avatar
Descartar

Hi,

I guess, Odoo standard tools do not allow it. You should develop your own js widget. Have a look here: https://www.odoo.com/documentation/8.0/reference/javascript.html

Mejor respuesta

Hello juan Vicente pascual,  

     you have to make one api method in your python code. at the top of python file  import datetime.


@api.onchange('dependent field name')
    def formate_date(self):
        self.your field name = datetime.datetime.strptime(self.dependent field name, '%Y-%m-%d').strftime('%B)

here, "dependent field name" is field name  which has date, and "formate_date" is a method name.

Hope this will help you, thanks!

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
4
ago 24
77341
4
dic 23
24226
0
mar 16
3387
0
dic 15
4434
2
may 25
1776