Odoo Help

0
1
Dipak Shah
On 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.

Thank you, this works fine..

Silviaa
on 2/13/18, 11:29 PM
2
Avatar

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
12459
| 6 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)
On 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

--Yenthe--
10849
| 8 8 8
Belgium
--Yenthe--

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

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

Yenthe
On 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
On 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

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

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

1 follower(s)

Stats

Asked: 2/13/18, 7:16 AM
Seen: 961 times
Last updated: 2/27/18, 5:23 AM