This question has been flagged
2 Replies
3016 Views

I've created a domain for display last 12 hours orders, but it doesn't work correctly...

<field name="domain">[('create_date','&gt;=', (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))),

('create_date','&lt;=', ((datetime.datetime.now()- datetime.timedelta(hours=12)).strftime('%Y-%m-%d %H:%M:%S'))) ]</field>


Avatar
Discard
Author

I am getting following error: Uncaught Error: TypeError: unsupported operand type(s) for -: 'datetime' and 'timedelta'.

Best Answer

Hello,

Please write down your domain  as like below, it will work.

<field name="domain">[('create_date','&gt;=', (time.strftime('%%Y-%%m-%%d %%H:%%M:%%S'))),
('create_date','&lt;=', ((context_today() - datetime.timedelta(hours=12)).strftime('%%Y-%%m-%%d %%H:%%M:%%S'))) ]</field>


Please try with this and give your result. Hope it will work for you.


Avatar
Discard
Author

Thanks for your help... But still I am getting following error using this code: "Error: ValueError: No known conversion for %H"