I have this code like this in odoo 11
@api.multi
def report_team(self):
teambao = self.env['hr.department'].search([])
tongteam = len(teambao)
i = 0
while i < tongteam:
if teambao[i].id:
now = datetime.now()
print(now.date())
project = self.env['project.project'].search([('deadline', '=', now.date())])
print (project)
i = i + 1
And when i run this function, it getting error like this
"object of type 'datetime.date' has no len()" while evaluating 'model.report_team()'
in report_team
project = self.env['project.project'].search([('deadline', '=', now.date())])
All I want is get the project that have deadline at today
Any suggest for me?
Thanks
You should convert the date to a string for comparison:
project = self.env['project.project'].search([('deadline', '=', str(now.date()))])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With