From 4fd400982c88d8e8d6eed3aa3560fb813564e386 Mon Sep 17 00:00:00 2001 From: Paramjit Singh Sahota Date: Mon, 10 Dec 2012 10:55:54 +0530 Subject: [PATCH] [IMP] Reverted the onchange_enddate functions code. And make it as was in previous. bzr revid: psa@tinyerp.com-20121210052554-hw7ep3rvvi3fr7wg --- addons/mrp_operations/mrp_operations.py | 32 ++++++------------- addons/mrp_operations/mrp_operations_view.xml | 6 ++-- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index beeb4389e8f..aaaa14c5309 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -52,40 +52,26 @@ stock_move() class mrp_production_workcenter_line(osv.osv): - def _calculate_end_date(self, cr, uid, date_planned, hour, calendar_id, context=None): - if not date_planned: - return False - date_and_hours_by_cal =[ (date_planned, hour, calendar_id)] - intervals = self.pool.get('resource.calendar').interval_get_multi(cr, uid, date_and_hours_by_cal) - if intervals: - i = intervals.get((date_planned, hour, calendar_id)) - if i: - res = i[-1][1].strftime('%Y-%m-%d %H:%M:%S') - else: - res = date_planned - return res - def _get_date_end(self, cr, uid, ids, field_name, arg, context=None): """ Finds ending date. @return: Dictionary of values. """ ops = self.browse(cr, uid, ids, context=context) + date_and_hours_by_cal = [(op.date_planned, op.hour, op.workcenter_id.calendar_id.id) for op in ops if op.date_planned] + + intervals = self.pool.get('resource.calendar').interval_get_multi(cr, uid, date_and_hours_by_cal) + res = {} for op in ops: res[op.id] = False if op.date_planned: - res[op.id] = self._calculate_end_date(cr, uid, op.date_planned, op.hour, op.workcenter_id.calendar_id.id) - else: - res[op.id] = op.date_planned + i = intervals.get((op.date_planned, op.hour, op.workcenter_id.calendar_id.id)) + if i: + res[op.id] = i[-1][1].strftime('%Y-%m-%d %H:%M:%S') + else: + res[op.id] = op.date_planned return res - def onchange_date_planned(self, cr, uid, ids, date_planned, hour, workcenter_id, context=None): - res = {} - if workcenter_id: - workcenter = self.pool.get("mrp.workcenter").browse(cr, uid, workcenter_id, context=context) - res['date_planned_end'] = self._calculate_end_date(cr, uid, date_planned, hour, workcenter.calendar_id.id) - return {'value': res} - def onchange_production_id(self, cr, uid, ids, production_id, context=None): products = self.pool.get('mrp.production').browse(cr, uid, production_id, context=None) result = { diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml index 6d0a451648a..dbe5ed83d0d 100644 --- a/addons/mrp_operations/mrp_operations_view.xml +++ b/addons/mrp_operations/mrp_operations_view.xml @@ -75,7 +75,7 @@ - + @@ -84,13 +84,13 @@ - + - +