Odoo Help

1

Function to calculate number of days between FROM and TO but it won't calculate weekends(sat and sun) ?

By
babu
on 4/29/14, 2:10 PM 1,619 views

In the "Leave request" it calculates duration between From and To, But it will calculate the sunday and saturday i don't want to calculate these two dates.

I hope U can understand my problem

Thanks in advance

Sorryyyyyyyy for my bad english

2

Sudhir Arya (ERP Harbor Consulting Services)

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

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 4/29/14, 4:14 PM

Hi Madhubabu,

Following code may help you to count number of days between two dates except weekends.

>>> from datetime import date,timedelta
>>> fromdate = date(2014, 4, 1)
>>> todate = date(2014, 4, 30)
>>> daygenerator = [fromdate + timedelta(x + 1) for x in xrange((todate - fromdate).days)]
>>> daygenerator += [fromdate + timedelta(0)]
>>> sum(1 for day in daygenerator if day.weekday() < 5)
22

Hope this may help you.

Thanks a lot Sudhir Arya. It's working fine.

babu
on 4/30/14, 1:44 PM

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

Question tools

0 follower(s)

Stats

Asked: 4/29/14, 2:10 PM
Seen: 1619 times
Last updated: 3/16/15, 8:10 AM