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

I changed date format from Languages ,then its change in odoo interface.But in Reports its coming in different format need a help..

Attached screen shots  


This is for reports screen shots-----

http://prntscr.com/ixyq6s


Language (odoo )screenshot --

http://prntscr.com/ixyr0a

Required format is mm/dd/yy but in reports yy/mm/dd

How i can solve this issue?

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

Hi,

First you need to find user’s language date format like as follows,

user_date_format = self.env['res.lang']._lang_get(self.env.user.lang).date_format


Then use the following line to change your fields in report


date_from = datetime.strptime(str(self.date_from), '%Y-%m-d').strftime(str(user_date_format))
date_to = datetime.strptime(str(self.date_to), '%Y-%m-%d').strftime(str(user_date_format))


Regards

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

H e llo 

You Need To Change It Manually from Report XML Code,

So First You Have Inherit That Report And Using Xpath You Have To Add Attribute For Particular Format of Date That You Want.


Because Changes You Have That Only For Odoo View, For Report You Must Have Inherit The Report and Apply Changes. 


For Example


< span t-field = "field_name" t-field-options = '{"format": "Mdy"}' />



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

Need to manually change whole reports?

No You Have to Inherit Report And Change only Particular That Date Field. or You can Replace That Date Field With New One.

الكاتب

okay..

أفضل إجابة

By default it should be converted automatically according to the language setting of the related partner. If the language of the partner is not set, it is set to the language setting of the user.

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

Language of partner already set as English..and format is dd-mm-yy

الكاتب

you are talking about by prefernce menu right?

أفضل إجابة

First of all you need to converting datetime.date to datetime.datetime

start_date = datetime.strptime(s_date.strftime('%Y%m%d'), '%Y%m%d')

Date formatting in Qweb reports (dd-mm-yy):

<h5 class="pull-right" style="position:relative; top: 2px; margin:0;"><u>Printed Date: <span t-esc="time.strftime('%d-%b-%Y')"></span></u></h5>

For more detail visit: http://learnopenerp.blogspot.com/2016/09/how-to-convert-datetimedate-to.html

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

But i am not talking about a single report.Like i need to change in whole report without chnage each field date format