Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object of type "datetime.date" has no len ()" in python

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

like image 664
Thai Laoquoc Avatar asked Oct 17 '18 01:10

Thai Laoquoc


1 Answers

You should convert the date to a string for comparison:

project = self.env['project.project'].search([('deadline', '=', str(now.date()))])
like image 63
blhsing Avatar answered Oct 12 '22 12:10

blhsing