콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
7 답글
21251 화면

Hi everyone,


Could someone please offer any assistance with the following;

I am attempting to modify the "Due Payments" report (View name: account.report_overdue_document) to list dates in the UK date format, i.e. for the 18th April 2017, I would like the dates to be shown as: 18/04/2017

I want this format to apply to all dates in the report; i.e. the report issue date and all transaction dates listed in the report.


The key snippets of code to be modified are:


<span t-esc="Date"/>        <!-- Report issue date -->


<tr t-foreach="Lines[o.id][currency]" t-as="line">
                            <td>
                                <span t-esc="line['move_id']"/>
                            </td>
                            <td>
                                <span t-esc="line['date']"/>          <!-- Invoice Date: Needs to be UK date format-->
                            </td>
                            <td>
                                <span t-esc="line['date_maturity']"/> <!-- Due Date: Needs to be UK date format -->
                            </td>


I have tried using a combination of the .strf and t-field options as shown in other posts but I'm obviously not getting the syntax right (I'm still I noob to Odoo!) so any assistance would be grately appreciated. 


Many thanks.

아바타
취소
베스트 답변

Hi  David knowles

<sapn t-esc="datetime.datetime.strptime(your field name, '%Y-%m-%d %H:%M:%S').strftime('%d/%m/%Y')"/>

you should to use this code.

Hope this will help you, Thanks!

아바타
취소
베스트 답변

hello,

I work on :

<span t-esc="Date"/>

and I try to change the format, and I use :

Date: <span t-esc="Date.strftime('%d-%m-%Y')" /><br/>

"Date" is a "datetime" object, if yours others dates are "datetime" objects so this solution is the right one.

아바타
취소
베스트 답변

<span t-esc="line['date_maturity']" t-field-options='{"format": "MM/dd/yyyy"}'/>


Change the format to UK format

아바타
취소
베스트 답변
<span t-esc="datetime.datetime.strptime(your field name, '%Y-%m-%d %H:%M:%S').strftime('%d/%m/%Y')"/>

아바타
취소
작성자 베스트 답변

Hi Esther,

Thanks for your response, I've already tried that syntax and it does not appear to work.

I thought that t-field-options could only be applied to t-fields and not t-esc?


I also tried your second suggestion and the Odoo 10 (CE) server had the following error:


Error to render compiling AST
TypeError: 'NoneType' object has no attribute '__getitem__'
Template: account.report_overdue_document
Path: /templates/t/t/div/div/div[2]/p/span[2]
Node: <span t-esc="formatLang(line['date_maturity'], date=True)"/>



아바타
취소

Try this, the language must be UK

<span t-esc="formatLang(line['date_maturity'], date=True)"/>

작성자

I also tried your second suggestion and the Odoo 10 (CE) server had the following error:

Error to render compiling AST

TypeError: 'NoneType' object has no attribute '__getitem__'

Template: account.report_overdue_document

Path: /templates/t/t/div/div/div[2]/p/span[2]

Node: <span t-esc="formatLang(line['date_maturity'], date=True)"/>

관련 게시물 답글 화면 활동
1
2월 25
953
0
10월 23
2235
3
12월 24
4502
1
9월 21
4528
6
12월 23
21618