跳至內容
選單
此問題已被標幟
7 回覆
21218 瀏覽次數

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
934
0
10月 23
2196
3
12月 24
4453
1
9月 21
4504
6
12月 23
21586