تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
15635 أدوات العرض

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
أغسطس 24
77484
4
ديسمبر 23
24249
0
مارس 16
3398
0
ديسمبر 15
4442
2
مايو 25
1797