[IMP] Improved onchange.

bzr revid: psa@tinyerp.com-20121206090038-umqu0sce210mtmpp
This commit is contained in:
Paramjit Singh Sahota 2012-12-06 14:30:38 +05:30
parent af1b13b489
commit bd8250a3cb
2 changed files with 9 additions and 11 deletions

View File

@ -26,7 +26,6 @@ import time
from datetime import datetime
from tools.translate import _
from datetime import timedelta
from dateutil.relativedelta import relativedelta
#----------------------------------------------------------
# Work Centers
@ -72,14 +71,13 @@ class mrp_production_workcenter_line(osv.osv):
res[op.id] = op.date_planned
return res
# def onchange_get_date_end(self, cr, uid, ids, workcenter_id, date_planned, cycle, hour, context=None):
def onchange_get_date_end(self, cr, uid, ids, workcenter_id, date_planned, cycle, hour, context=None):
def onchange_get_date_end(self, cr, uid, ids, date_planned, cycle, hour):
res = {'value':{}}
yo = cycle * hour
if date_planned and isinstance(date_planned, str):
cycle_per_hour = timedelta(hours=(cycle * hour))
if date_planned :
date_planned = datetime.strptime(date_planned, "%Y-%m-%d %H:%M:%S")
date_planned_end = date_planned + timedelta(hours=yo)
res['value'] = {'date_planned_end': date_planned_end.strftime("%Y-%m-%d %H:%M:%S")}
date_planned_end = date_planned + cycle_per_hour
res['value'] = {'date_planned_end': date_planned_end.strftime("%Y-%m-%d %H:%M:%S")}
return res
# def onchange_get_date_end(self, cr, uid, ids, date_planned, cycle, hour, context=None):

View File

@ -75,7 +75,7 @@
<sheet string="Work Orders">
<group col="4">
<field colspan="2" name="name"/>
<field name="workcenter_id" on_change="onchange_get_date_end(date_planned, cycle, hour, 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_get_date_end(workcenter_id, date_planned, cycle, hour, context)"/>
<field name="date_planned" on_change="onchange_get_date_end(date_planned, cycle, hour)"/>
<field name="date_planned_end"/>
</group>
<group string="Duration">
<field name="cycle"/>
<field name="hour" widget="float_time"/>
<field name="cycle" on_change="onchange_get_date_end(date_planned, cycle, hour)"/>
<field name="hour" widget="float_time" on_change="onchange_get_date_end(date_planned, cycle, hour)"/>
</group>
<group string="Actual Production Date" >
<field name="date_start" readonly="1"/>