[IMP] Improved code for the End Date field: which should be updated automatically if you change the Scheduled Date.
bzr revid: psa@tinyerp.com-20121203062209-t57bjlhw0vkraeg0
This commit is contained in:
parent
77a640594e
commit
4521ee8108
|
@ -56,9 +56,7 @@ class mrp_production_workcenter_line(osv.osv):
|
|||
@return: Dictionary of values.
|
||||
"""
|
||||
ops = self.browse(cr, uid, ids, context=context)
|
||||
print "ops????????????/", ops
|
||||
date_and_hours_by_cal = [(op.date_planned, op.hour, op.workcenter_id.calendar_id.id) for op in ops if op.date_planned]
|
||||
print "date_and_hours_by_cal>>>>>", date_and_hours_by_cal
|
||||
intervals = self.pool.get('resource.calendar').interval_get_multi(cr, uid, date_and_hours_by_cal)
|
||||
|
||||
res = {}
|
||||
|
@ -72,17 +70,8 @@ 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):
|
||||
""" Finds ending date from schedule date's onchange.
|
||||
"""
|
||||
# date_and_hours_by_cal = [(date_planned,hour, 1)]
|
||||
# intervals = self.pool.get('resource.calendar').interval_get_multi(cr, uid, date_and_hours_by_cal)
|
||||
# i = intervals.get((date_planned,hour, 1))
|
||||
# if i:
|
||||
# res = i[-1][1].strftime('%Y-%m-%d %H:%M:%S')
|
||||
# else:
|
||||
# res = date_planned
|
||||
work_ids=self.search(cr,uid,[('workcenter_id','=',workcenter_id)],context=context)
|
||||
def onchange_get_date_end(self, cr, uid, ids, workcenter_id, date_planned, cycle, hour, context=None):
|
||||
work_ids = self.search(cr,uid,[('workcenter_id','=',workcenter_id)],context=context)
|
||||
ops = self.browse(cr, uid, work_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)
|
||||
|
@ -93,14 +82,10 @@ class mrp_production_workcenter_line(osv.osv):
|
|||
if i:
|
||||
res= i[-1][1].strftime('%Y-%m-%d %H:%M:%S')
|
||||
else:
|
||||
res = date_planned
|
||||
res = op.date_planned
|
||||
return {'value':{'date_planned_end': res}}
|
||||
|
||||
def onchange_production_id(self, cr, uid, ids, production_id, context=None):
|
||||
""" Finds UoM of changed product.
|
||||
@param product_id: Id of changed product.
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
products = self.pool.get('mrp.production').browse(cr, uid, production_id, context=None)
|
||||
result = {
|
||||
'product': products.product_id.id,
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
<sheet string="Work Orders">
|
||||
<group col="4">
|
||||
<field colspan="2" name="name"/>
|
||||
<field name="workcenter_id"/>
|
||||
<field name="workcenter_id" on_change="onchange_get_date_end(date_planned, cycle, hour, context)"/>
|
||||
<field name="production_id" on_change="onchange_production_id(production_id)"/>
|
||||
<field name="production_state"/>
|
||||
<field name="sequence"/>
|
||||
|
@ -84,7 +84,7 @@
|
|||
<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(workcenter_id, date_planned, cycle, hour, context)"/>
|
||||
<field name="date_planned_end"/>
|
||||
</group>
|
||||
|
||||
|
|
Loading…
Reference in New Issue