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

Hello All, 

Any one know how to change date format in xlsx report .

Now Current date print (yyyy-mm-dd) so i want to change in (dd-mm-yyyy)

so any one suggest me how to achieved this ?  

الصورة الرمزية
إهمال
أفضل إجابة

Added report_xlsx (https://apps.odoo.com/apps/modules/14.0/report_xlsx/) module from oca and follow this step:

Add below code inside the function:

date_style = workbook.add_format({'text_wrap': True, 'num_format': 'dd-mm-yyyy'})
sheet = workbook.add_worksheet(report_name[:31])
sheet.write(row, col, "Created on: ", bold)
sheet.write(row, col + 1, proj.created_on, date_style)

Hope it will work.

الصورة الرمزية
إهمال

Hi, can you specify where to add the above code.. im trying to add in ir_report.py inside def _render_xlsx(self, report_ref, docids, data): this function...but i didn't get any results

الكاتب أفضل إجابة

Hello All

I am  Solve using this:

import datetime
 datetime.datetime.strptime(obj.start_date, '%Y-%m-%d').strftime('%d-%m-%Y')
الصورة الرمزية
إهمال

This worked for me, thanks. Also it canbe used to pass only the year from the date format i.e datetime.datetime.strptime(obj.start_date, '%Y-%m-%d').strftime('%Y')

Which place did you add this code

أفضل إجابة

Hi Manish,

you have to change the date format in the language settings

Activate the developer mode > Settings > Translations > Select the language you are using > and in the field "'Date Format" enter the format you want 


this will change the format of the date in the entire system and will reflect in printing xls reports 

الصورة الرمزية
إهمال
الكاتب

sorry It's not solved my problem.

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 24
2557
1
يونيو 24
5020
1
أكتوبر 23
10704
1
أكتوبر 23
98
1
أغسطس 23
2193