Dear all,
I am having problems on comparing 2 dates in Odoo 12.
I have a variable that contains a date. If I print it I get:
>> print(date)
2019-05-11
I also have a field of date type with a calender widget set on xml.
So, when I print it's value I get:
>> print vals.get('date')
2019-05-11
The problem is that I am unable to compare both fields. I get no error and the "if statement" is not read.
if date == vals.get('date'):
print("Date is equal")
The full code is:
registos = self.env['mymodule.mymodel'].search([('myfield.id','=',value_to_search)])
for rec in registos:
date = rec.date
if date == vals.get('date'):
print("Date is equal")
What's wrong here?
Thank you in advance
Best regards
Paulo
Can you just check whether both the fields/value or of same data type...
Thank you @Niyas.
This was exactly the problem. Both values had different type values.
vals.get('date') #string
rec.date #date
I have solved the issue.
Thank you once again