[MERGE] branch merged with lp:~openerp-dev/openobject-addons/trunk-leave-req-imp-dbr
bzr revid: mtr@tinyerp.com-20120725123345-3vidbhuoww8lk4pf
This commit is contained in:
commit
f1893b88c6
|
@ -112,7 +112,7 @@ class hr_holidays(osv.osv):
|
|||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Description', required=True, size=64),
|
||||
'name': fields.text('Description', required=True,states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}),
|
||||
'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.\
|
||||
|
@ -126,7 +126,6 @@ class hr_holidays(osv.osv):
|
|||
#'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)]}),
|
||||
'number_of_days': fields.function(_compute_number_of_days, string='Number of Days', store=True),
|
||||
'meeting_id': fields.many2one('crm.meeting', 'Meeting'),
|
||||
|
@ -147,14 +146,13 @@ 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))", "My user has no employee."),
|
||||
('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):
|
||||
|
@ -269,7 +267,7 @@ class hr_holidays(osv.osv):
|
|||
'name': record.name,
|
||||
'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,
|
||||
'description': record.name,
|
||||
'user_id': record.user_id.id,
|
||||
'date': record.date_from,
|
||||
'end_date': record.date_to,
|
||||
|
@ -375,18 +373,11 @@ class hr_holidays(osv.osv):
|
|||
if obj.employee_id.parent_id and not obj.employee_id.parent_id.user_id.id in user_ids:
|
||||
user_ids.append(obj.employee_id.parent_id.user_id.id)
|
||||
return user_ids
|
||||
|
||||
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)
|
||||
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.")
|
||||
_("The %s request has been <b>submitted</b> and is waiting for validation by the manager.")
|
||||
% ('leave' if obj.type == 'remove' else 'allocation',), type='notification')
|
||||
|
||||
def holidays_validate_notificate(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
</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="type">form</field>
|
||||
|
@ -102,7 +102,6 @@
|
|||
<field name="arch" type="xml">
|
||||
<form 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"/>
|
||||
|
@ -111,30 +110,29 @@
|
|||
</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 colspan="4">
|
||||
<group>
|
||||
<group>
|
||||
<field name="manager_id" groups="base.group_no_one"/>
|
||||
<field name="double_validation" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
|
@ -142,9 +140,8 @@
|
|||
</group>
|
||||
</group>
|
||||
<newline/>
|
||||
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..."/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="name" nolabel="1" attrs="{'readonly':[('state','!=','draft'),('state','!=','confirm')]}" placeholder="Add a reason..."/>
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
|
||||
|
@ -161,7 +158,6 @@
|
|||
<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"/>
|
||||
|
@ -171,27 +167,21 @@
|
|||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<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)" 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="holiday_status_id" on_change="onchange_status_id(holiday_status_id)" context="{'employee_id':employee_id}"/>
|
||||
<field name="number_of_days_temp"/>
|
||||
</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>
|
||||
<group>
|
||||
<field name="double_validation" invisible="1"/>
|
||||
<field name="manager_id2" attrs="{'invisible':[('double_validation', '!=', True)]}"/>
|
||||
</group>
|
||||
<field name="name" placeholder="Add a reason..."/>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_ids" colspan="4" widget="mail_thread" nolabel="1"/>
|
||||
|
@ -237,7 +227,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')]}"/>
|
||||
|
@ -245,7 +234,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>
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
<record model="workflow.transition" id="t1">
|
||||
<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">
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<?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>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue