Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Try this friend:
from datetime import date
from datetime import datetime, date, time
ref_id = False
y = False
m = False
state = False
d = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
d_ref = datetime.strptime("2011-01-11","%Y-%m-%d")
d_to = datetime.strptime("2012-01-31","%Y-%m-%d")
if d_ref < d_to :
d_ref = d_to
y = d_to.year
m = d_to.month
day = d_to.day
You can eliminate the day :)
From Date field you will get date as string, first convert it to datetime object type using:
date = datetime.strptime([your string date], "%Y-%m-%d")
then you can simply use datetime attributes to get month and year as:
" print date.month, print date.year......."
To show it in another field you can use on_change() method of [your date] field.
Don't forgot to import datetime at top as;
"from datetime import datetime"
Hope it helps you !
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
|Asked: 8/13/15, 6:32 AM|
|Seen: 3663 times|
|Last updated: 7/6/17, 9:47 AM|