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

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.





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

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

Лучший ответ

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!

Аватар
Отменить
Related Posts Ответы Просмотры Активность
4
авг. 24
77413
4
дек. 23
24231
0
мар. 16
3393
0
дек. 15
4440
2
мая 25
1784