Odoo Help

0
5 Answers
1
Dipak Shah
2/13/18, 8:03 AM
Hello \Silviaa,

Try this ,

import dateutil.rrule as rrule

from datetime import date

feb_date_list = list(rrule.rrule(rrule.WEEKLY,dtstart=date(2018,2,1),until=date(2018,2,28),byweekday=rrule.MO))

print feb_date_list

---------------------------------

* By changing 'dtstart' and 'until' parameter you can do it for any month / year / duration.

Hope this will help you !

Thanks,
Dipak.

1 Comment
Silviaa
2/13/18, 11:29 PM

Thank you, this works fine..

2
Avatar

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
13045
| 7 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

ERP Harbor Consulting Services

Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Sudhir Arya (ERP Harbor Consulting Services)
2/13/18, 8:06 AM

Hi,

You could have done it by little R&D, googling.

Try following code:

import time
from datetime import datetime
from calendar import monthrange

year = int(time.strftime('%Y'))
month = int(time.strftime('%m'))
for day in range(1, monthrange(year, month)[1] + 1):
dt = datetime(year, month, day)
if dt.weekday() == 0: # 0 for Monday, 1 for Tue and so on....
print dt

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com  website: http://www.erpharbor.com
0
Avatar

Yenthe Van Ginneken

--Yenthe Van Ginneken--
13705
| 8 8 10
Belgium
--Yenthe Van Ginneken--

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666


Yenthe Van Ginneken
2/13/18, 8:03 AM

Hi Silviaa,

This question is rather about Python than just Odoo but to answer your question: you should use the Python packages date, datetime or calendar in order to get these values out. There are quite some ways to do this, but here is an example with the calendar package:

import calendar

c = calendar.Calendar(firstweekday=calendar.MONDAY) year = 2018; month = 2 monthcal = c.monthdatescalendar(year,month) mondays = [day for week in monthcal for day in week if \ day.weekday() == calendar.MONDAY and \ day.month == month] for monday in mondays: print('monday: ' + str(monday))

Or an example with datetime:

import datetime

today = datetime.date.today() day = datetime.date(today.year, today.month, 1) single_day = datetime.timedelta(days=1) mondays = 0 dates = [] while day.month == today.month: if day.weekday() == 0: mondays += 1 dates.append(day) day += single_day print('Number of mondays this month:'+ str(mondays)) for date in dates: print('date: ' + str(date))

Regards,
Yenthe

0
Sehrish
2/19/18, 2:08 AM

Check out date manipulation in python

http://learnopenerp.blogspot.com/2018/01/python-date-manipulation.html

Use python strftime method to date and time formatting

http://learnopenerp.blogspot.com/2018/02/python-strftime-datetime-formatting.html

Ask a Question
Writer
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