Odoo Help


Covert date_due from string to datetime.date

on 6/24/13, 7:57 AM 3,092 views

I am trying to work with the due date in account.invoice, i want the difference of current date an date_due but i get this error. ValueError: time data 'inv.date_due' does not match format '%m-%d-%Y %H:%M:%S'

my code is:

def _get_date_difference(self, cr, uid, ids, field_name, arg,context):
        for inv in self.browse(cr,uid,ids):            
            dt=datetime.strptime('inv.date_due', '%m-%d-%Y %H:%M:%S').date()
##            if inv.payment_term and inv.state == "open":
            res[inv.id] = abs((datetime.now()-dt).days)
        return res

Francesco OpenCode

--Francesco OpenCode--

| 6 8 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 6/24/13, 8:50 AM

Read datetime documentation, in particulare the strptime function doc.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/24/13, 7:57 AM
Seen: 3092 times
Last updated: 3/16/15, 8:10 AM