[FIX] hr_holidays: better display of leave counter (opw 605016)

The number of leave requests left is based on the employee_id key in the context, when displaying the status of an hr.holidays we don't have the information in the name_get of the hr.holidays.status.
The fallback on the number of employees is done with the uid but we can not rely on it as well as the name_get on m2o field is done with superuser_id.

bzr revid: mat@openerp.com-20140508124946-ttyr84iajg9q6l0y
This commit is contained in:
Martin Trigaux 2014-05-08 14:49:46 +02:00
parent 133c5033a0
commit c636fb9dd9
2 changed files with 7 additions and 2 deletions

View File

@ -95,6 +95,11 @@ class hr_holidays_status(osv.osv):
def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
if not context.get('employee_id',False):
# leave counts is based on empoyee_id, would be inaccurate if not based on correct employee
return super(hr_holidays_status, self).name_get(cr, uid, ids, context=context)
res = []
for record in self.browse(cr, uid, ids, context=context):
name = record.name

View File

@ -78,7 +78,7 @@
<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="holiday_type" on_change="onchange_type(holiday_type)" attrs="{'readonly':[('state','!=','draft')]}" width="130" string="Mode" groups="base.group_hr_user" context="{'employee_id':employee_id}" />
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','=','category')]}" on_change="onchange_employee(employee_id)" groups="base.group_hr_user"/>
<field name="department_id" attrs="{'readonly':[('holiday_type','=','category')]}" groups="base.group_hr_user"/>
</group>
@ -116,7 +116,7 @@
</div>
</group>
<group>
<field name="holiday_type" on_change="onchange_type(holiday_type)"/>
<field name="holiday_type" on_change="onchange_type(holiday_type)" context="{'employee_id':employee_id}" />
<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')]}"/>