Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Current datetime in XML

By
mehdi
on 8/5/15, 2:02 PM 2,340 views

hello,

i use current date time in python (time.strftime) without problem but i can't in XML file when i try to insert colors into tree view !

<tree string="Mission" colors="blue:datetime_field > time.strftime('%d-%m-%Y %H:%M:%S')">

i test datetime.datetime.now() and DateTime.today() but no result !

0
Abhishek H Menon
On 7/9/16, 11:11 AM

Use the variable current_date instead of using other date calls. you will get the result

0
mehdi
On 8/5/15, 7:00 PM

the current_date as a string of the form yyyy-MM-dd but i work with date time format like this ('%d-%m-%Y %H:%M:%S') and when i work with current_date there is a difference of 1 day because this function dont use time detail

In that case, you must create a customization for /web/static/src/js/view_tree.js Line 37.

Serpent Consulting Services Pvt. Ltd.
on 8/6/15, 9:45 AM

Thank you for this post but in this file the creation of current_date is : current_date: new Date().toString('yyyy-MM-dd') you have an idea for creation of current_datetime with this format ('%d-%m-%Y %H:%M:%S') ?

mehdi
on 8/6/15, 11:11 AM
0

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 8/5/15, 2:39 PM

Mehdi,

Use Date() for Kanban.

For tree comparison, use current_date. In any domain,can use datetime.datetime.now().strftime('%Y-%m-%d').

See for the Tasks as an example:

<tree fonts="bold:message_unread==True" colors="red:date_deadline and (date_deadline&lt;current_date)" string="Tasks">

Thanks.

the current_date as a string of the form yyyy-MM-dd but i work with date time format like this ('%d-%m-%Y %H:%M:%S') and when i work with current_date there is a difference of 1 day because this function dont use time detail

mehdi
on 8/5/15, 7:00 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 8/5/15, 2:02 PM
Seen: 2340 times
Last updated: 7/9/16, 11:11 AM