[6.1][7.0][trunk] All planned dates are not computed by working (business) days

Bug #1115042 reported by Yann Papouin
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP R&D Addons Team 2

Bug Description

When I set a delay of 6 day(s) to manufacture a product, I do not expect to finish it during the weekend !!!

All delays must be computed with the configured working days of a company:
http://www.free-online-calculator-use.com/business-day-calculator.html

Actually I changed all date computation from (example):

    def _get_date_planned(self, cr, uid, order, line, start_date, context=None):
        date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0)
        date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
        return date_planned

to:

    def _get_date_planned(self, cr, uid, order, line, start_date, context=None):
        dt_startdate = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT)
        count = (line.delay or 0.0)
        if count > 0:
              date_planned = dt_startdate + relativedelta(list(rrule(DAILY, count=count, byweekday=(MO,TU,WE,TH,FR)))[-1], dt_startdate)
         else:
              date_planned = dt_startdate

        date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
        return date_planned

But it will be better to have "res.config" parameter where we can set (check) working days (for each company):

[X] Monday
[X] Tuesday
[X] Wednesday
[X] Thursday
[X] Friday
[ ] Saturday
[ ] Sunday

And a generic function (in tools) to compute delays from this settings that could be used by all addons the same way.
This function should allow forward delay:
  eg: delivered_date = now + delay
And backward delay:
  eg: manufacture_start_date = delivered_date - manufacture_delay

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

I think the Akretion folks presented a module doing this during the 2012 community days. You should query them about this on the community mailing list.

Now, I agree with you that OpenERP should be dealing with this.

Revision history for this message
Yann Papouin (yann-papouin) wrote :

I didn't found anything about this in watching repositories.
A good start could be to use an existing library: https://bitbucket.org/shelldweller/python-bizdatetime

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Yann,

Its good improvement and we can consider this as a feature road-maps.

Thanks for the reporting!

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Sebastien LANGE - http://www.Syleam.fr (alnslang) wrote :

Sylean has developed a module for manage it.

The parameter is per company because one company can wotk saturday and other one not.

The link of this module : https://github.com/syleam/base_workingdays

Revision history for this message
Yann Papouin (yann-papouin) wrote :

Hi Sebastien, your module base_workingdays seems really great but I don't understand how it works without patching modules.
Some refactoring on standard modules (sale,stock,purchase,account,mrp, etc.) is necessary to correctly implement this feature.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.