[IMP] Reverted the onchange_enddate functions code. And make it as was in previous.

bzr revid: psa@tinyerp.com-20121210052554-hw7ep3rvvi3fr7wg
This commit is contained in:
Paramjit Singh Sahota
2012-12-10 10:55:54 +05:30
parent c5ef9fa145
commit 4fd400982c
2 changed files with 12 additions and 26 deletions
+9 -23
View File
@@ -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 = {
@@ -75,7 +75,7 @@
<sheet string="Work Orders">
<group col="4">
<field colspan="2" name="name"/>
<field name="workcenter_id" on_change="onchange_date_planned(date_planned, hour, workcenter_id, context)"/>
<field name="workcenter_id"/>
<field name="production_id" on_change="onchange_production_id(production_id)"/>
<field name="production_state"/>
<field name="sequence"/>
@@ -84,13 +84,13 @@
<page string="Information">
<group>
<group string="Planned Date">
<field name="date_planned" on_change="onchange_date_planned(date_planned, hour, workcenter_id, context)"/>
<field name="date_planned"/>
<field name="date_planned_end"/>
</group>
<group string="Duration">
<field name="cycle"/>
<field name="hour" widget="float_time" on_change="onchange_date_planned(date_planned, hour, workcenter_id, context)"/>
<field name="hour" widget="float_time"/>
</group>
<group string="Actual Production Date" >
<field name="date_start" readonly="1"/>