Skip to Content
Menu
This question has been flagged
1 Reply
1597 Views

Hello,

I'm currently working on a new model and I'm trying to group the timestamp on hour basis.

As I can see it is implemented in Odoo15 (see pathtoodoo/odoo/models.py line 2281)

   def _read_group_process_groupby(self, gb, query): 
   'hour': 'hh:00 dd MMM',


Now I have a datetimefield based on this format:

dd.MM.yyyy hh:mm:ss


But I can only group by day, week, month, quarter, year, does someone know what I need to do to group by hour?


Best 
Max

Avatar
Discard
Best Answer

Hello Max, 

i think you can store that hours to other float field with float_time widget after that you can use that field as group by.

may be it will help you!

Best Regards,
Jay Gajera

Avatar
Discard
Author

Hello Jay,

thank you for your answer.

I tried it now with the timestamp as float field, but this doesn't work to.

How should the float_time as float field be formated?
- 2022-05-09 16:00
- 1652104989

Do you have an example for me?

Thank you very much! :)