Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
11 ตอบกลับ
9300 มุมมอง

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