[MERGE] merged branch with leave request improvements
bzr revid: qdp-launchpad@openerp.com-20120831144244-40apxljf6juyv3nv
This commit is contained in:
commit
fc8855fa74
|
@ -25,6 +25,7 @@ import datetime, time
|
|||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
|
||||
import math
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
@ -112,7 +113,7 @@ class hr_holidays(osv.osv):
|
|||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Description', required=True, size=64),
|
||||
'name': fields.char('Description', size=64),
|
||||
'state': fields.selection([('draft', 'To Submit'), ('cancel', 'Cancelled'),('confirm', 'To Approve'), ('refuse', 'Refused'), ('validate1', 'Second Approval'), ('validate', 'Approved')],
|
||||
'State', readonly=True, help='The state is set to \'To Submit\', when a holiday request is created.\
|
||||
\nThe state is \'To Approve\', when holiday request is confirmed by user.\
|
||||
|
@ -123,8 +124,6 @@ class hr_holidays(osv.osv):
|
|||
'date_to': fields.datetime('End Date', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'holiday_status_id': fields.many2one("hr.holidays.status", "Leave Type", required=True,readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'employee_id': fields.many2one('hr.employee', "Employee", select=True, invisible=False, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, help='Leave Manager can let this field empty if this leave request/allocation is for every employee'),
|
||||
#'manager_id': fields.many2one('hr.employee', 'Leave Manager', invisible=False, readonly=True, help='This area is automatically filled by the user who validate the leave'),
|
||||
#'notes': fields.text('Notes',readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'manager_id': fields.many2one('hr.employee', 'First Approval', invisible=False, readonly=True, help='This area is automatically filled by the user who validate the leave'),
|
||||
'notes': fields.text('Reasons',readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'number_of_days_temp': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
|
@ -134,8 +133,8 @@ class hr_holidays(osv.osv):
|
|||
'parent_id': fields.many2one('hr.holidays', 'Parent'),
|
||||
'linked_request_ids': fields.one2many('hr.holidays', 'parent_id', 'Linked Requests',),
|
||||
'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),
|
||||
'category_id': fields.many2one('hr.employee.category', "Category", help='Category of Employee', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'holiday_type': fields.selection([('employee','By Employee'),('category','By Employee Category')], 'Allocation Mode', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, 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)'),
|
||||
'double_validation': fields.related('holiday_status_id', 'double_validation', type='boolean', relation='hr.holidays.status', string='Apply Double Validation'),
|
||||
}
|
||||
|
@ -147,16 +146,11 @@ class hr_holidays(osv.osv):
|
|||
'holiday_type': 'employee'
|
||||
}
|
||||
_sql_constraints = [
|
||||
('type_value', "CHECK( (holiday_type='employee' AND employee_id IS NOT NULL) or (holiday_type='category' AND category_id IS NOT NULL))", "You have to select an employee or a category."),
|
||||
('type_value', "CHECK( (holiday_type='employee' AND employee_id IS NOT NULL) or (holiday_type='category' AND category_id IS NOT NULL))", "The employee or employee category of this request is missing."),
|
||||
('date_check2', "CHECK ( (type='add') OR (date_from <= date_to))", "The start date must be before the end date !"),
|
||||
('date_check', "CHECK ( number_of_days_temp >= 0 )", "The number of days must be greater than 0 !"),
|
||||
]
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
obj_id = super(hr_holidays, self).create(cr, uid, vals, context=context)
|
||||
self.create_notificate(cr, uid, [obj_id], context=context)
|
||||
return obj_id
|
||||
|
||||
def _create_resource_leave(self, cr, uid, leaves, context=None):
|
||||
'''This method will create entry in resource calendar leave object at the time of holidays validated '''
|
||||
obj_res_leave = self.pool.get('resource.calendar.leaves')
|
||||
|
@ -201,8 +195,8 @@ class hr_holidays(osv.osv):
|
|||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
for rec in self.browse(cr, uid, ids, context=context):
|
||||
if rec.state<>'draft':
|
||||
raise osv.except_osv(_('Warning!'),_('You cannot delete a leave which is not in draft state !'))
|
||||
if rec.state not in ['draft', 'cancel', 'confirm']:
|
||||
raise osv.except_osv(_('Warning!'),_('You cannot delete a leave which is in %s state!')%(rec.state))
|
||||
return super(hr_holidays, self).unlink(cr, uid, ids, context)
|
||||
|
||||
def onchange_date_from(self, cr, uid, ids, date_to, date_from):
|
||||
|
@ -210,7 +204,7 @@ class hr_holidays(osv.osv):
|
|||
if date_to and date_from:
|
||||
diff_day = self._get_number_of_days(date_from, date_to)
|
||||
result['value'] = {
|
||||
'number_of_days_temp': round(diff_day)+1
|
||||
'number_of_days_temp': round(math.floor(diff_day))+1
|
||||
}
|
||||
return result
|
||||
result['value'] = {
|
||||
|
@ -244,29 +238,30 @@ class hr_holidays(osv.osv):
|
|||
self.unlink(cr, uid, to_unlink, context=context)
|
||||
return True
|
||||
|
||||
def holidays_validate(self, cr, uid, ids, context=None):
|
||||
def holidays_first_validate(self, cr, uid, ids, context=None):
|
||||
self.check_holidays(cr, uid, ids, context=context)
|
||||
obj_emp = self.pool.get('hr.employee')
|
||||
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
|
||||
manager = ids2 and ids2[0] or False
|
||||
self.holidays_validate_notificate(cr, uid, ids, context=context)
|
||||
self.holidays_first_validate_notificate(cr, uid, ids, context=context)
|
||||
return self.write(cr, uid, ids, {'state':'validate1', 'manager_id': manager})
|
||||
|
||||
def holidays_validate2(self, cr, uid, ids, context=None):
|
||||
def holidays_validate(self, cr, uid, ids, context=None):
|
||||
self.check_holidays(cr, uid, ids, context=context)
|
||||
obj_emp = self.pool.get('hr.employee')
|
||||
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
|
||||
manager = ids2 and ids2[0] or False
|
||||
self.write(cr, uid, ids, {'state':'validate'})
|
||||
data_holiday = self.browse(cr, uid, ids)
|
||||
holiday_ids = []
|
||||
for record in data_holiday:
|
||||
if record.holiday_status_id.double_validation:
|
||||
holiday_ids.append(record.id)
|
||||
if record.double_validation:
|
||||
self.write(cr, uid, [record.id], {'manager_id2': manager})
|
||||
else:
|
||||
self.write(cr, uid, [record.id], {'manager_id': manager})
|
||||
if record.holiday_type == 'employee' and record.type == 'remove':
|
||||
meeting_obj = self.pool.get('crm.meeting')
|
||||
meeting_vals = {
|
||||
'name': record.name,
|
||||
'name': record.name or _('Leave Request'),
|
||||
'categ_ids': record.holiday_status_id.categ_id and [(6,0,[record.holiday_status_id.categ_id.id])] or [],
|
||||
'duration': record.number_of_days_temp * 8,
|
||||
'description': record.notes,
|
||||
|
@ -301,25 +296,27 @@ 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)
|
||||
if holiday_ids:
|
||||
self.holidays_valid2_notificate(cr, uid, holiday_ids, context=context)
|
||||
self.write(cr, uid, holiday_ids, {'manager_id2': manager})
|
||||
self.holidays_validate_notificate(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def holidays_confirm(self, cr, uid, ids, context=None):
|
||||
self.check_holidays(cr, uid, ids, context=context)
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
if record.employee_id and record.employee_id.parent_id and record.employee_id.parent_id.user_id:
|
||||
self.message_subscribe(cr, uid, [record.id], user_ids=[record.employee_id.parent_id.user_id.id], context=context)
|
||||
self.holidays_confirm_notificate(cr, uid, ids, context=context)
|
||||
return self.write(cr, uid, ids, {'state':'confirm'})
|
||||
|
||||
def holidays_refuse(self, cr, uid, ids, approval, context=None):
|
||||
def holidays_refuse(self, cr, uid, ids, context=None):
|
||||
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, {'state': 'refuse', 'manager_id': manager})
|
||||
else:
|
||||
self.write(cr, uid, ids, {'state': 'refuse', 'manager_id2': manager})
|
||||
self.holidays_refuse_notificate(cr, uid, ids, approval, context=context)
|
||||
for holiday in self.browse(cr, uid, ids, context=context):
|
||||
if holiday.state == 'validate1':
|
||||
self.write(cr, uid, [holiday.id], {'state': 'refuse', 'manager_id': manager})
|
||||
else:
|
||||
self.write(cr, uid, [holiday.id], {'state': 'refuse', 'manager_id2': manager})
|
||||
self.holidays_refuse_notificate(cr, uid, ids, context=context)
|
||||
self.holidays_cancel(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
|
@ -333,7 +330,7 @@ class hr_holidays(osv.osv):
|
|||
# If a category that created several holidays, cancel all related
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for request in record.linked_request_ids or []:
|
||||
wf_service.trg_validate(uid, 'hr.holidays', request.id, 'cancel', cr)
|
||||
wf_service.trg_validate(uid, 'hr.holidays', request.id, 'refuse', cr)
|
||||
|
||||
self._remove_resource_leave(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
@ -355,7 +352,7 @@ class hr_holidays(osv.osv):
|
|||
def get_needaction_user_ids(self, cr, uid, ids, context=None):
|
||||
result = super(hr_holidays, self).get_needaction_user_ids(cr, uid, ids, context=context)
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if obj.state == 'confirm' and obj.employee_id.parent_id:
|
||||
if obj.state == 'confirm' and obj.holiday_type == 'employee' and obj.employee_id.parent_id:
|
||||
result[obj.id] = [obj.employee_id.parent_id.user_id.id]
|
||||
elif obj.state == 'validate1':
|
||||
# get group_hr_manager: everyone will be warned of second validation
|
||||
|
@ -369,44 +366,38 @@ class hr_holidays(osv.osv):
|
|||
def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
|
||||
""" Add 'user_id' and 'manager' to the monitored fields """
|
||||
res = super(hr_holidays, self).message_get_monitored_follower_fields(cr, uid, ids, context=context)
|
||||
# TODO: add manager
|
||||
return res + ['user_id']
|
||||
|
||||
def create_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_append_note(cr, uid, ids, _('System notification'),
|
||||
_("The %s request has been <b>created</b> and is waiting confirmation.")
|
||||
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
|
||||
_("The request has been <b>created</b> and is waiting confirmation."), type='notification', context=context)
|
||||
return True
|
||||
|
||||
def holidays_confirm_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
self.message_append_note(cr, uid, [obj.id], _('System notification'),
|
||||
_("The %s request has been <b>confirmed</b> and is waiting for validation by the manager.")
|
||||
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification')
|
||||
_("The request has been <b>submitted</b> and is waiting for validation by the manager."), type='notification')
|
||||
|
||||
def holidays_first_validate_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_append_note(cr, uid, [obj.id], _('System notification'),
|
||||
_("The request has been <b>approved</b>. A second validation is necessary and is now pending."), type='notification', context=context)
|
||||
|
||||
def holidays_validate_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
if obj.holiday_status_id.double_validation:
|
||||
if obj.double_validation:
|
||||
self.message_append_note(cr, uid, [obj.id], _('System notification'),
|
||||
_("The %s request has been <b>approved</b>. A second validation is necessary and is now pending.")
|
||||
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
|
||||
_("The request has been <b>double validated</b>. The validation process is now over."), type='notification', context=context)
|
||||
else:
|
||||
self.message_append_note(cr, uid, [obj.id], _('System notification'),
|
||||
_("The %s request has been <b>approved</b>. The validation process is now over.")
|
||||
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
|
||||
_("The request has been <b>approved</b>. The validation process is now over."), type='notification', context=context)
|
||||
|
||||
def holidays_valid2_notificate(self, cr, uid, ids, context=None):
|
||||
|
||||
def holidays_refuse_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
self.message_append_note(cr, uid, [obj.id], _('System notification'),
|
||||
_("The %s request has been <b>double validated</b>. The validation process is now over.")
|
||||
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
|
||||
|
||||
def holidays_refuse_notificate(self, cr, uid, ids, approval, context=None):
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
self.message_append_note(cr, uid, [obj.id], _('System notification'),
|
||||
_("The %s request has been <b>refused</b>. The validation process is now over.")
|
||||
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
|
||||
_("The request has been <b>refused</b>. The validation process is now over."), type='notification', context=context)
|
||||
|
||||
hr_holidays()
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<record model="hr.holidays" id="hr_holidays_employee1_cl">
|
||||
<field name="name">Trip with Family</field>
|
||||
<field name="holiday_status_id" ref="holiday_status_cl"/>
|
||||
<field name="holiday_status_id" ref="holiday_status_comp"/>
|
||||
<field eval="time.strftime('%Y-%m-01')" name="date_from"/>
|
||||
<field eval="time.strftime('%Y-%m-03')" name="date_to"/>
|
||||
<field name="type">remove</field>
|
||||
|
@ -52,13 +52,10 @@
|
|||
<field name="employee_id" ref="hr.employee_fp"/>
|
||||
</record>
|
||||
|
||||
<workflow action="confirm" model="hr.holidays" ref="hr_holidays_employee1_allocation_cl"/>
|
||||
<workflow action="validate" model="hr.holidays" ref="hr_holidays_employee1_allocation_cl"/>
|
||||
|
||||
<workflow action="confirm" model="hr.holidays" ref="hr_holidays_employee1_sl"/>
|
||||
<workflow action="validate" model="hr.holidays" ref="hr_holidays_employee1_sl"/>
|
||||
|
||||
<workflow action="confirm" model="hr.holidays" ref="hr_holidays_employee1_int_tour"/>
|
||||
<workflow action="validate" model="hr.holidays" ref="hr_holidays_employee1_int_tour"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -84,56 +84,42 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="edit_holiday_new">
|
||||
<record model="ir.ui.view" id="edit_holiday_new">
|
||||
<field name="name">Leave Request</field>
|
||||
<field name="model">hr.holidays</field>
|
||||
<field name="priority">1</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Leave Request" version="7.0">
|
||||
<header>
|
||||
<button string="Submit to Manager" name="confirm" states="draft" type="workflow" class="oe_highlight"/>
|
||||
<button string="Approve" name="validate" states="confirm" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Validate" name="second_validate" states="validate1" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Refuse" name="refuse" states="confirm,validate1" type="workflow" groups="base.group_hr_user,base.group_hr_manager" class="oe_highlight"/>
|
||||
<button string="Reset to New" name="set_to_draft" states="refuse,validate" type="object" groups="base.group_hr_user" />
|
||||
<button string="Refuse" name="refuse" states="confirm,validate1,validate" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Reset to New" name="set_to_draft" states="refuse" type="object" groups="base.group_hr_user" />
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}'/>
|
||||
</header>
|
||||
<sheet string="Leave Request">
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" attrs="{'readonly':[('state','!=','draft'),('state','!=','confirm')]}"/>
|
||||
<field name="holiday_type" on_change="onchange_type(holiday_type)" attrs="{'readonly':[('state','!=','draft')]}" width="130" string="Mode" groups="base.group_hr_user"/>
|
||||
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','=','category')]}" groups="base.group_hr_user"/>
|
||||
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'invisible':[('holiday_type','=','employee')], 'readonly':[('state','!=','draft'), ('state','!=','confirm')]}"/>
|
||||
<field name="department_id" attrs="{'readonly':[('holiday_type','=','category')]}" groups="base.group_hr_user"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="holiday_status_id" on_change="onchange_status_id(holiday_status_id)" context="{'employee_id':employee_id}"/>
|
||||
<label for="number_of_days_temp" string="Duration"/>
|
||||
<div>
|
||||
<field name="date_from" on_change="onchange_date_from(date_to, date_from)" required="1" class="oe_inline"/> -
|
||||
<field name="date_to" on_change="onchange_date_from(date_to, date_from)" required="1" class="oe_inline"/>
|
||||
<group col="3">
|
||||
<field name="date_from" nolabel="1" on_change="onchange_date_from(date_to, date_from)" required="1" class="oe_inline"/><label string="-" class="oe_inline" />
|
||||
<field name="date_to" nolabel="1" on_change="onchange_date_from(date_to, date_from)" required="1" class="oe_inline"/>
|
||||
</group>
|
||||
<div>
|
||||
<field name="number_of_days_temp" class="oe_inline"/> days
|
||||
</div>
|
||||
</div>
|
||||
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'invisible':[('holiday_type','=','employee')], 'readonly':[('state','!=','draft'), ('state','!=','confirm')]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="holiday_type" on_change="onchange_type(holiday_type)" attrs="{'readonly':[('state','!=','draft')]}" width="130" string="Mode" groups="base.group_hr_user"/>
|
||||
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','=','category')]}" groups="base.group_hr_user"/>
|
||||
<field name="department_id" attrs="{'readonly':[('holiday_type','=','category')]}" groups="base.group_hr_user"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="General">
|
||||
<group>
|
||||
<group>
|
||||
<field name="manager_id" groups="base.group_no_one"/>
|
||||
<field name="double_validation" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="manager_id2" attrs="{'invisible':[('double_validation', '!=', True)]}" groups="base.group_no_one"/>
|
||||
</group>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..."/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
|
||||
|
@ -150,37 +136,27 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Allocation Request" version="7.0">
|
||||
<header>
|
||||
<button string="Submit to Manager" name="confirm" states="draft" type="workflow" class="oe_highlight"/>
|
||||
<button string="Approve" name="validate" states="confirm" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Validate" name="second_validate" states="validate1" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Refuse" name="refuse" states="confirm,validate1" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Reset to New" name="set_to_draft" states="cancel,validate,refuse" type="object" groups="base.group_hr_user" />
|
||||
<button string="Refuse" name="refuse" states="confirm,validate,validate1" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
|
||||
<button string="Reset to New" name="set_to_draft" states="cancel,refuse" type="object" groups="base.group_hr_user" />
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}'/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="holiday_type" on_change="onchange_type(holiday_type)" attrs="{'readonly':[('state','!=','draft')]}" string="Allocation Mode" groups="base.group_hr_manager"/>
|
||||
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')], 'invisible':[('holiday_type','=','category')]}"/>
|
||||
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'readonly':[('state','!=','draft')], 'invisible':[('holiday_type','=','employee')]}"/>
|
||||
<field name="department_id" attrs="{'readonly':['|', ('holiday_type','=','category'), ('state','not in' ,('draft', 'confirm'))]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="name" required="1" attrs="{'readonly':[('state','!=','draft'),('state','!=','confirm')]}"/>
|
||||
<field name="holiday_status_id" on_change="onchange_status_id(holiday_status_id)" context="{'employee_id':employee_id}"/>
|
||||
<field name="number_of_days_temp"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="holiday_type" on_change="onchange_type(holiday_type)"/>
|
||||
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')], 'invisible':[('holiday_type','=','category')]}"/>
|
||||
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'invisible':[('holiday_type','=','employee')]}"/>
|
||||
<field name="department_id" attrs="{'invisible':[('holiday_type','=','category')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="General">
|
||||
<group col="4">
|
||||
<field name="double_validation" invisible="1"/>
|
||||
<field name="manager_id"/>
|
||||
<field name="manager_id2" attrs="{'invisible':[('double_validation', '!=', True)]}"/>
|
||||
</group>
|
||||
<field name="notes" placeholder="Add a reason..."/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..."/>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
|
||||
|
@ -225,7 +201,6 @@
|
|||
<field name="state"/>
|
||||
</header>
|
||||
<group col="4">
|
||||
<field name="name"/>
|
||||
<field name="holiday_status_id"/>
|
||||
<field name="type"/>
|
||||
<field name="date_from" on_change="onchange_date_from(date_to, date_from)" attrs="{'readonly':[('type','=','add')], 'required':[('type','=','remove')]}"/>
|
||||
|
@ -233,7 +208,7 @@
|
|||
<field name="number_of_days_temp"/>
|
||||
<field name="manager_id"/>
|
||||
</group>
|
||||
<field name="notes"/>
|
||||
<field name="name" placeholder="Add a reason..."/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -288,12 +263,12 @@
|
|||
<menuitem name="Leaves" parent="hr.menu_hr_root" id="menu_open_ask_holidays" sequence="20"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="open_ask_holidays">
|
||||
<field name="name">Leave Requests</field>
|
||||
<field name="name">My Leave Requests</field>
|
||||
<field name="res_model">hr.holidays</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="edit_holiday_new"/>
|
||||
<field name="context">{}</field>
|
||||
<field name="domain">[('type','=','remove')]</field>
|
||||
<field name="domain">[('type','=','remove'),('employee_id.user_id','=', uid)]</field>
|
||||
<field name="search_view_id" ref="view_hr_holidays_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
|
@ -327,7 +302,7 @@
|
|||
<field name="view_id" ref="view_holiday_new_calendar"/>
|
||||
<field name="act_window_id" ref="open_ask_holidays"/>
|
||||
</record>
|
||||
|
||||
|
||||
<menuitem name="My Leave Requests" parent="menu_open_ask_holidays" id="menu_open_ask_holidays_new" action="open_ask_holidays"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="request_approve_holidays">
|
||||
|
@ -357,11 +332,11 @@
|
|||
<menuitem name="Leave Requests to Approve" parent="menu_open_ask_holidays" id="menu_request_approve_holidays" action="request_approve_holidays" groups="base.group_hr_user"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="open_allocation_holidays">
|
||||
<field name="name">Allocation Requests</field>
|
||||
<field name="name">My Allocation Requests</field>
|
||||
<field name="res_model">hr.holidays</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="context">{'default_type':'add'}</field>
|
||||
<field name="domain">[('type','=','add')]</field>
|
||||
<field name="domain">[('type','=','add'),('employee_id.user_id','=', uid)]</field>
|
||||
<field name="view_id" ref="allocation_leave_new"/>
|
||||
<field name="search_view_id" ref="view_hr_holidays_filter"/>
|
||||
</record>
|
||||
|
@ -380,7 +355,7 @@
|
|||
<field name="act_window_id" ref="open_allocation_holidays"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="Allocation Requests" parent="menu_open_ask_holidays" id="menu_open_allocation_holidays" action="open_allocation_holidays"/>
|
||||
<menuitem name="My Allocation Requests" parent="menu_open_ask_holidays" id="menu_open_allocation_holidays" action="open_allocation_holidays"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="open_company_allocation">
|
||||
<field name="name">Leaves Summary</field>
|
||||
|
|
|
@ -2,7 +2,16 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Workflow definition -->
|
||||
<!-- Workflow definition
|
||||
1. draft->submitted (no signal)
|
||||
2. submitted->accepted (validate signal) if not double_validation
|
||||
2. submitted -> first_accepted (validate signal) if double_validation
|
||||
2. submitted->refused (refuse signal)
|
||||
3. accepted->refused (refuse signal)
|
||||
4. first_accepted -> accepted (second_validate signal)
|
||||
4. first_accepted -> refused (refuse signal)
|
||||
|
||||
-->
|
||||
|
||||
<record model="workflow" id="wkf_holidays">
|
||||
<field name="name">hr.wkf.holidays</field>
|
||||
|
@ -10,13 +19,13 @@
|
|||
<field name="on_create">True</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_draft">
|
||||
<record model="workflow.activity" id="act_draft"> <!-- draft -->
|
||||
<field name="wkf_id" ref="wkf_holidays" />
|
||||
<field name="flow_start">True</field>
|
||||
<field name="name">draft</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_confirm">
|
||||
<record model="workflow.activity" id="act_confirm"> <!-- submitted -->
|
||||
<field name="wkf_id" ref="wkf_holidays" />
|
||||
<field name="name">confirm</field>
|
||||
<field name="kind">function</field>
|
||||
|
@ -24,74 +33,94 @@
|
|||
<field name="split_mode">OR</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_validate">
|
||||
<record model="workflow.activity" id="act_validate"> <!-- accepted -->
|
||||
<field name="wkf_id" ref="wkf_holidays" />
|
||||
<field name="name">validate</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">holidays_validate()</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_validate1">
|
||||
<record model="workflow.activity" id="act_validate1"> <!-- first_accepted -->
|
||||
<field name="wkf_id" ref="wkf_holidays" />
|
||||
<field name="name">second_validate</field>
|
||||
<field name="name">first_validate</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">holidays_validate2()</field>
|
||||
<field name="action">holidays_first_validate()</field>
|
||||
<field name="split_mode">OR</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="workflow.activity" id="act_refuse">
|
||||
<record model="workflow.activity" id="act_refuse"> <!-- refused -->
|
||||
<field name="wkf_id" ref="wkf_holidays" />
|
||||
<field name="name">refuse</field>
|
||||
<field name="flow_stop">True</field>
|
||||
<field name="kind">stopall</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">holidays_refuse()</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
workflow transition
|
||||
-->
|
||||
|
||||
<record model="workflow.transition" id="t1">
|
||||
<record model="workflow.transition" id="holiday_draft2confirm"> <!-- 1. draft->submitted (no signal) -->
|
||||
<field name="act_from" ref="act_draft" />
|
||||
<field name="act_to" ref="act_confirm" />
|
||||
<field name="signal">confirm</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="t2">
|
||||
<record model="workflow.transition" id="holiday_confirm2validate"> <!-- 2. submitted->accepted (validate signal) if not double_validation-->
|
||||
<field name="act_from" ref="act_confirm" />
|
||||
<field name="act_to" ref="act_validate" />
|
||||
<field name="signal">validate</field>
|
||||
<field name="condition">not double_validation</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="holiday_confirm2validate1"> <!-- 2. submitted -> first_accepted (validate signal) if double_validation-->
|
||||
<field name="act_from" ref="act_confirm" />
|
||||
<field name="act_to" ref="act_validate1" />
|
||||
<field name="condition">double_validation</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="workflow.transition" id="holiday_confirm2refuse"> <!-- 2. submitted->refused (refuse signal) -->
|
||||
<field name="act_from" ref="act_confirm" />
|
||||
<field name="act_to" ref="act_refuse" />
|
||||
<field name="signal">refuse</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="t3">
|
||||
<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>
|
||||
|
||||
<record model="workflow.transition" id="t4">
|
||||
<record model="workflow.transition" id="holiday_validate2refuse"> <!-- 3. accepted->refused (refuse signal) -->
|
||||
<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="condition">True</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="t8">
|
||||
<record model="workflow.transition" id="holiday_validate2refuse"> <!-- 3. accepted->refused (refuse signal) -->
|
||||
<field name="act_from" ref="act_validate" />
|
||||
<field name="act_to" ref="act_validate1" />
|
||||
<field name="act_to" ref="act_refuse" />
|
||||
<field name="signal">refuse</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="workflow.transition" id="holiday_validate1_validate"> <!-- 4. first_accepted -> accepted (second_validate signal) -->
|
||||
<field name="act_from" ref="act_validate1" />
|
||||
<field name="act_to" ref="act_validate" />
|
||||
<field name="condition">True</field>
|
||||
<field name="signal">second_validate</field>
|
||||
<field name="group_id" ref="base.group_hr_manager" />
|
||||
<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" />
|
||||
<field name="condition">not holiday_status_id.double_validation</field>
|
||||
<field name="signal" eval="False"/>
|
||||
<record model="workflow.transition" id="holiday_validate1_refuse"> <!-- 4. first_accepted->refused (refuse signal) -->
|
||||
<field name="act_from" ref="act_validate1" />
|
||||
<field name="act_to" ref="act_refuse" />
|
||||
<field name="signal">refuse</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="group_id" ref="base.group_hr_user"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
|
|
@ -4,5 +4,5 @@ access_hr_holidays_user,hr.holidays.user,model_hr_holidays,base.group_hr_user,1,
|
|||
access_hr_holidays_employee,hr.holidays.employee,model_hr_holidays,base.group_user,1,1,1,1
|
||||
access_hr_holydays_status_employee,hr.holidays.status employee,model_hr_holidays_status,base.group_user,1,0,0,0
|
||||
access_hr_holidays_remain_user,hr.holidays.ramain.user,model_hr_holidays_remaining_leaves_user,base.group_hr_user,1,1,1,1
|
||||
access_resource_calendar_leaves_manager,resource_calendar_leaves_manager,resource.model_resource_calendar_leaves,base.group_hr_manager,1,1,1,1
|
||||
access_resource_calendar_leaves_user,resource_calendar_leaves_user,resource.model_resource_calendar_leaves,base.group_hr_user,1,1,1,1
|
||||
access_crm_meeting_type_manager,crm.meeting.type.manager,base_calendar.model_crm_meeting_type,base.group_hr_manager,1,1,1,1
|
||||
|
|
|
|
@ -1,6 +1,19 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="property_rule_holidays_employee" model="ir.rule">
|
||||
<field name="name">Employee Holidays</field>
|
||||
<field model="ir.model" name="model_id" ref="model_hr_holidays"/>
|
||||
<field name="domain_force">[('employee_id.user_id','=',user.id)]</field>
|
||||
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="property_rule_holidays_officer" model="ir.rule">
|
||||
<field name="name">Holidays Officer</field>
|
||||
<field model="ir.model" name="model_id" ref="model_hr_holidays"/>
|
||||
<field name="domain_force">[(1,'=',1)]</field>
|
||||
<field name="groups" eval="[(4,ref('base.group_hr_user'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue