← Back to team overview

openerp-india team mailing list archive

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

 

Public bug reported:

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

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1115042

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

Status in OpenERP Addons (modules):
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1115042/+subscriptions


Follow ups

References