This question has been flagged
7 Replies
19045 Views

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.

Avatar
Discard
Best Answer

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!

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

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


Change the format to UK format

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

Avatar
Discard
Author Best Answer

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)"/>



Avatar
Discard

Try this, the language must be UK

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

Author

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)"/>