Skip to Content
Menu
This question has been flagged
2 Replies
14927 Views

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
Discard

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

Best Answer

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
Discard
Related Posts Replies Views Activity
4
Aug 24
70780
4
Dec 23
22808
0
Mar 16
2323
0
Dec 15
2950
2
Oct 24
184