Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
39989 Переглядів

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 !

Аватар
Відмінити
Найкраща відповідь

Hi

1.First create a compute field: 

current_time = fields.Datetime(string='Current time', compute='_get_current_time')


def _get_current_time(self):
for li in self:
li.current_time = fields.datetime.now()

2. Then use this in your xml:


Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Автор Найкраща відповідь

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.

Автор

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,

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

Related Posts Відповіді Переглядів Дія
2
січ. 23
27186
1
груд. 20
2977
1
квіт. 18
8170
3
вер. 15
9937
2
серп. 15
5816