[IMP] hr_holidays: Workflow with second validator
bzr revid: mra@tinyerp.com-20100514091331-iafdwpxf958lrm5j
This commit is contained in:
parent
02cad04eda
commit
8cc68f9e66
|
@ -252,7 +252,6 @@ class hr_holidays(osv.osv):
|
|||
}
|
||||
return {'warning': warning}
|
||||
|
||||
|
||||
def set_to_draft(self, cr, uid, ids, *args):
|
||||
self.write(cr, uid, ids, {
|
||||
'state':'draft',
|
||||
|
@ -265,11 +264,26 @@ class hr_holidays(osv.osv):
|
|||
return True
|
||||
|
||||
def holidays_validate2(self, cr, uid, ids, *args):
|
||||
vals = {'state':'validate'}
|
||||
data_holiday = self.browse(cr, uid, ids)
|
||||
vals = {'state':'validate1'}
|
||||
self.check_holidays(cr, uid, ids)
|
||||
ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
|
||||
if ids2:
|
||||
vals['manager_id2'] = ids2[0]
|
||||
vals['manager_id'] = ids2[0]
|
||||
else:
|
||||
raise osv.except_osv(_('Warning !'),_('No user related to the selected employee.'))
|
||||
self.write(cr, uid, ids, vals)
|
||||
return True
|
||||
|
||||
def holidays_validate(self, cr, uid, ids, *args):
|
||||
data_holiday = self.browse(cr, uid, ids)
|
||||
self.check_holidays(cr, uid, ids)
|
||||
vals = {'state':'validate'}
|
||||
ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
|
||||
if ids2:
|
||||
if data_holiday[0].state == 'validate1':
|
||||
vals['manager_id2'] = ids2[0]
|
||||
else:
|
||||
vals['manager_id'] = ids2[0]
|
||||
else:
|
||||
raise osv.except_osv(_('Warning !'),_('No user related to the selected employee.'))
|
||||
self.write(cr, uid, ids, vals)
|
||||
|
@ -287,34 +301,6 @@ class hr_holidays(osv.osv):
|
|||
self.pool.get('resource.calendar.leaves').create(cr, uid, vals)
|
||||
return True
|
||||
|
||||
def holidays_validate(self, cr, uid, ids, *args):
|
||||
data_holiday = self.browse(cr, uid, ids)
|
||||
self.check_holidays(cr, uid, ids)
|
||||
if data_holiday[0].holiday_status_id.double_validation:
|
||||
vals = {'state':'validate1'}
|
||||
else:
|
||||
vals = {'state':'validate'}
|
||||
ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
|
||||
if ids2:
|
||||
vals['manager_id'] = ids2[0]
|
||||
else:
|
||||
raise osv.except_osv(_('Warning !'),_('No user related to the selected employee.'))
|
||||
self.write(cr, uid, ids, vals)
|
||||
if not data_holiday[0].holiday_status_id.double_validation:
|
||||
for record in data_holiday:
|
||||
if record.holiday_type=='employee' and record.type=='remove':
|
||||
vals = {
|
||||
'name':record.name,
|
||||
'date_from':record.date_from,
|
||||
'date_to':record.date_to,
|
||||
'calendar_id':record.employee_id.calendar_id.id,
|
||||
'company_id':record.employee_id.company_id.id,
|
||||
'resource_id':record.employee_id.resource_id.id,
|
||||
'holiday_id':record.id
|
||||
}
|
||||
self.pool.get('resource.calendar.leaves').create(cr, uid, vals)
|
||||
return True
|
||||
|
||||
def holidays_confirm(self, cr, uid, ids, *args):
|
||||
for record in self.browse(cr, uid, ids):
|
||||
user_id = False
|
||||
|
@ -342,7 +328,6 @@ class hr_holidays(osv.osv):
|
|||
'number_of_days': nb,
|
||||
'user_id': user_id
|
||||
})
|
||||
cr.commit()
|
||||
return True
|
||||
|
||||
def holidays_refuse(self, cr, uid, ids, *args):
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
<field name="act_from" ref="act_confirm" />
|
||||
<field name="act_to" ref="act_validate" />
|
||||
<field name="signal">validate</field>
|
||||
<field name="condition">(holiday_status_id.double_validation == False)</field>
|
||||
<field name="role_id" ref="HR_holidays"/>
|
||||
</record>
|
||||
|
||||
|
@ -107,21 +108,29 @@
|
|||
</record>
|
||||
|
||||
<record model="workflow.transition" id="t8">
|
||||
<field name="act_from" ref="act_validate" />
|
||||
<field name="act_to" ref="act_validate1" />
|
||||
<field name="act_from" ref="act_validate1" />
|
||||
<field name="act_to" ref="act_validate" />
|
||||
<field name="signal">second_validate</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="t9">
|
||||
<!--<record model="workflow.transition" id="t9">
|
||||
<field name="act_from" ref="act_validate" />
|
||||
<field name="act_to" ref="act_refuse" />
|
||||
<field name="signal">refuse</field>
|
||||
</record>-->
|
||||
|
||||
<record model="workflow.transition" id="t10">
|
||||
<field name="act_from" ref="act_validate1" />
|
||||
<field name="act_to" ref="act_refuse" />
|
||||
<field name="signal">refuse</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="t10">
|
||||
<field name="act_from" ref="act_validate1" />
|
||||
<field name="act_to" ref="act_cancel" />
|
||||
<field name="signal">cancel</field>
|
||||
<record model="workflow.transition" id="t11">
|
||||
<field name="act_from" ref="act_confirm" />
|
||||
<field name="act_to" ref="act_validate1" />
|
||||
<field name="condition">(holiday_status_id.double_validation == True)</field>
|
||||
<field name="signal">validate</field>
|
||||
<field name="role_id" ref="HR_holidays"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue