Odoo Help

0
2 Answers
0
Islamic Relief Canada
7‏/6‏/2018 6:27 ص

Hi Ayman,

I get this error "<class 'AttributeError'>: "module 'datetime' has no attribute 'strptime'" while evaluating"
then if I change it to t_date= datetime.datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").date() I get "Can't convert 'datetime.date' object to str implicitly" while evaluating
I am using Odoo Saas automated actions, date and datetime are available so I dont need to import


Edit:

The correct way of doing it is
t_date= datetime.datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").strftime('%Y-%m-%d')
hopefully it helps others as there is lack of Saas support

3 Comments
ayman mohammed adam
7‏/6‏/2018 6:39 ص

Make Print to ensure that is not null.

print " DDDDDDDDDD ", record.create_date

Cloudypedia, Islamic Relief Canada
7‏/6‏/2018 6:40 ص

i cannot do a print so i added it to a raise Warning and it works :)

Cloudypedia, Islamic Relief Canada
7‏/6‏/2018 6:55 ص

This is my code

t_date= datetime.datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").strftime('%Y-%m-%d')

if (t_date > record.date_invoice) :

raise Warning("Payment Date "+record.date_invoice+" cannot be before than the Donation Date"+" "+t_date)

0
Avatar

ayman mohammed adam

--ayman mohammed adam--
785
| 4 3 5
Riyadh, المملكة العربية السعودية
--ayman mohammed adam--


ayman mohammed adam
7‏/6‏/2018 6:22 ص

Dear Shaheryar Rajper,

 Try this:

from datetime import date, datetime,

t_date= datetime.strptime(record.create_date, "%Y-%m-%d %H:%M:%S").date()


I hope I helped You...

Ask a Question
Keep Informed
1 follower(s)
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.

Register
Odoo Training Center

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

Test it now