跳至内容
菜单
此问题已终结
2 回复
15645 查看

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!

形象
丢弃
相关帖文 回复 查看 活动
4
8月 24
77536
4
12月 23
24257
0
3月 16
3408
0
12月 15
4457
2
5月 25
1804