I have a method in which self
is a simple stock.move
record. Besides, as you may know, stock.move
model has a Datetime
field named date
. If I write this code inside the method:
lines = self.search([
('date', '=', self.date),
])
It should return me at least the current line. And it does, but only in some servers. Others return nothing. Why? Because if I do a query to get the date
in PostgreSQL, the servers which are working OK return 2017-12-27 17:10:00, however, the servers which are working wrong return 2017-12-27 17:10:00.131112. So, for the cases with miliseconds the ORM search
method is doing this:
lines = self.search([
(2017-12-27 17:10:00.131112, '=', 2017-12-27 17:10:00),
])
self.date
is returning the Datetime
value without the miliseconds and that's why the comparison fails. I need to get the miliseconds too.
How can I manage this?