[FIX] hr_holiday: hr_holidays: Second validation
bzr revid: ara@tinyerp.com-20110601051941-qijpncs4kcil7ek9
This commit is contained in:
parent
9d1c65eb21
commit
7ea9fdaa2c
|
@ -133,7 +133,8 @@ class hr_holidays(osv.osv):
|
|||
'department_id':fields.related('employee_id', 'department_id', string='Department', type='many2one', relation='hr.department', readonly=True, store=True),
|
||||
'category_id': fields.many2one('hr.employee.category', "Category", help='Category of Employee'),
|
||||
'holiday_type': fields.selection([('employee','By Employee'),('category','By Employee Category')], 'Allocation Type', help='By Employee: Allocation/Request for individual Employee, By Employee Category: Allocation/Request for group of employees in category', required=True),
|
||||
'manager_id2': fields.many2one('hr.employee', 'Second Approval', readonly=True, help='This area is automaticly filled by the user who validate the leave with second level (If Leave type need second validation)')
|
||||
'manager_id2': fields.many2one('hr.employee', 'Second Approval', readonly=True, help='This area is automaticly filled by the user who validate the leave with second level (If Leave type need second validation)'),
|
||||
'double_validation': fields.related('holiday_status_id', 'double_validation', type='boolean', relation='hr.holidays.status', string='Apply Double Validation'),
|
||||
}
|
||||
_defaults = {
|
||||
'employee_id': _employee_get,
|
||||
|
@ -235,10 +236,10 @@ class hr_holidays(osv.osv):
|
|||
manager = ids2 and ids2[0] or False
|
||||
self.write(cr, uid, ids, {'state':'validate'})
|
||||
data_holiday = self.browse(cr, uid, ids)
|
||||
holiday_ids = set()
|
||||
holiday_ids = []
|
||||
for record in data_holiday:
|
||||
if record.holiday_status_id.double_validation:
|
||||
holiday_ids.add(record.id)
|
||||
holiday_ids.append(record.id)
|
||||
if record.holiday_type == 'employee' and record.type == 'remove':
|
||||
meeting_obj = self.pool.get('crm.meeting')
|
||||
vals = {
|
||||
|
@ -275,7 +276,6 @@ class hr_holidays(osv.osv):
|
|||
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr)
|
||||
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr)
|
||||
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr)
|
||||
holiday_ids = list(holiday_ids)
|
||||
if holiday_ids:
|
||||
self.write(cr, uid, holiday_ids, {'manager_id2': manager})
|
||||
return True
|
||||
|
@ -284,10 +284,14 @@ class hr_holidays(osv.osv):
|
|||
self.check_holidays(cr, uid, ids)
|
||||
return self.write(cr, uid, ids, {'state':'confirm'})
|
||||
|
||||
def holidays_refuse(self, cr, uid, ids, *args):
|
||||
def holidays_refuse(self, cr, uid, ids, approval, *args):
|
||||
obj_emp = self.pool.get('hr.employee')
|
||||
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
|
||||
manager = ids2 and ids2[0] or False
|
||||
if approval == 'first_approval':
|
||||
self.write(cr, uid, ids, {'manager_id': manager})
|
||||
else:
|
||||
self.write(cr, uid, ids, {'manager_id2': manager})
|
||||
self.write(cr, uid, ids, {'state': 'refuse'})
|
||||
self.holidays_cancel(cr, uid, ids)
|
||||
return True
|
||||
|
@ -324,5 +328,4 @@ class resource_calendar_leaves(osv.osv):
|
|||
'holiday_id': fields.many2one("hr.holidays", "Holiday"),
|
||||
}
|
||||
|
||||
resource_calendar_leaves()
|
||||
|
||||
resource_calendar_leaves()
|
|
@ -85,19 +85,20 @@
|
|||
<field name="date_from" on_change="onchange_date_from(date_to, date_from)" required="1"/>
|
||||
<field name="date_to" on_change="onchange_date_from(date_to, date_from)" required="1"/>
|
||||
<field name="number_of_days_temp"/>
|
||||
<field name="double_validation" invisible="1"/>
|
||||
<newline/>
|
||||
<field name="manager_id"/>
|
||||
<field name="manager_id2"/>
|
||||
<field name="manager_id2" attrs="{'invisible':[('double_validation', '!=', True)]}"/>
|
||||
<separator string="Reasons" colspan="4"/>
|
||||
<field name="notes" nolabel="1" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="state" colspan="2"/>
|
||||
<group colspan="2" col="6">
|
||||
<button string="Refuse" name="refuse" states="confirm" type="workflow" icon="gtk-no" groups="base.group_hr_user,base.group_hr_manager"/>
|
||||
<button string="Refuse" name="refuse" states="confirm,validate1" type="workflow" icon="gtk-no" groups="base.group_hr_user,base.group_hr_manager"/>
|
||||
<button string="Confirm" name="confirm" states="draft" type="workflow" icon="gtk-yes"/>
|
||||
<button string="Approve" name="validate" states="confirm" type="workflow" icon="gtk-apply" groups="base.group_hr_user"/>
|
||||
<button string="Approved" name="second_validate" states="validate1" type="workflow" icon="gtk-apply" groups="base.group_hr_user"/>
|
||||
<button string="Set to Draft" name="set_to_draft" states="refuse,validate,validate1" type="object" icon="gtk-convert" groups="base.group_hr_user"/>
|
||||
<button string="Set to Draft" name="set_to_draft" states="refuse,validate" type="object" icon="gtk-convert" groups="base.group_hr_user"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
@ -127,19 +128,20 @@
|
|||
<field name="holiday_status_id" on_change="onchange_sec_id(holiday_status_id)" context="{'employee_id':employee_id}" />
|
||||
<field name="department_id" attrs="{'readonly':[('holiday_type','=','category')]}" />
|
||||
<field name="number_of_days_temp"/>
|
||||
<field name="double_validation" invisible="1"/>
|
||||
<newline/>
|
||||
<field name="manager_id"/>
|
||||
<field name="manager_id2"/>
|
||||
<field name="manager_id2" attrs="{'invisible':[('double_validation', '!=', True)]}"/>
|
||||
<separator string="Reasons" colspan="4"/>
|
||||
<field name="notes" nolabel="1" colspan="4" />
|
||||
<newline/>
|
||||
<field name="state" colspan="2"/>
|
||||
<group colspan="2" col="6">
|
||||
<button string="Refuse" name="refuse" states="confirm" type="workflow" icon="gtk-no" groups="base.group_hr_user"/>
|
||||
<button string="Refuse" name="refuse" states="confirm,validate1" type="workflow" icon="gtk-no" groups="base.group_hr_user"/>
|
||||
<button string="Confirm" name="confirm" states="draft" type="workflow" icon="gtk-yes"/>
|
||||
<button string="Approve" name="validate" states="confirm" type="workflow" icon="gtk-apply" groups="base.group_hr_user"/>
|
||||
<button string="Approved" name="second_validate" states="validate1" type="workflow" icon="gtk-apply" groups="base.group_hr_user"/>
|
||||
<button string="Set to Draft" name="set_to_draft" states="cancel,validate,validate1" type="object" icon="gtk-convert" groups="base.group_hr_user"/>
|
||||
<button string="Set to Draft" name="set_to_draft" states="cancel,validate" type="object" icon="gtk-convert" groups="base.group_hr_user"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
|
|
@ -42,10 +42,8 @@
|
|||
<record model="workflow.activity" id="act_refuse">
|
||||
<field name="wkf_id" ref="wkf_holidays" />
|
||||
<field name="name">refuse</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">stopall</field>
|
||||
<field name="action">holidays_refuse()</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
|
@ -70,6 +68,7 @@
|
|||
<field name="act_from" ref="act_confirm" />
|
||||
<field name="act_to" ref="act_refuse" />
|
||||
<field name="signal">refuse</field>
|
||||
<field name="condition">holidays_refuse('first_approval')</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
|
@ -77,6 +76,7 @@
|
|||
<field name="act_from" ref="act_validate" />
|
||||
<field name="act_to" ref="act_refuse" />
|
||||
<field name="signal">refuse</field>
|
||||
<field name="condition">holidays_refuse('second_approval')</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
|
@ -87,13 +87,6 @@
|
|||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</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>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="t11">
|
||||
<field name="act_from" ref="act_validate" />
|
||||
<field name="act_to" ref="act_validate1" />
|
||||
|
|
Loading…
Reference in New Issue