[REF] refactor date_planned

bzr revid: benoit.guillot@akretion.com.br-20111220094110-bay12ed4v850h0q6
This commit is contained in:
Benoit Guillot 2011-12-20 10:41:10 +01:00
parent cf34f051af
commit 688aaff712
1 changed files with 6 additions and 2 deletions

View File

@ -771,6 +771,11 @@ class sale_order(osv.osv):
self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
return True
def _get_date_planned(self, cr, uid, order, line, start_date, *args):
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
def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, *args):
"""Create the required procurements to supply sale order lines, also connecting
the procurements to appropriate stock moves in order to bring the goods to the
@ -799,8 +804,7 @@ class sale_order(osv.osv):
if line.state == 'done':
continue
date_planned = datetime.strptime(order.date_order, 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)
date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, *args)
if line.product_id:
if line.product_id.product_tmpl_id.type in ('product', 'consu'):