summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTejas Tank <tta@openerp.com>2013-02-11 16:27:01 +0530
committerTejas Tank <tta@openerp.com>2013-02-11 16:27:01 +0530
commit026e53d27a4dbd4fe48c6a95bffc2ecdc6e4e31d (patch)
tree34cf840b457604af0bd4d4475a7c258fd1007d58
parent6e22d502b91e2f1e21b3d09d2050333332182ad4 (diff)
[IMP] [Leaves] Context problem: creating a leave from the employee form.
bzr revid: tta@openerp.com-20130211105701-gzl5vsmx01ckdled
-rw-r--r--addons/hr_holidays/hr_holidays.py11
-rw-r--r--addons/hr_holidays/hr_holidays_view.xml2
2 files changed, 8 insertions, 5 deletions
diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py
index c7d7867911d..11b3cef41cd 100644
--- a/addons/hr_holidays/hr_holidays.py
+++ b/addons/hr_holidays/hr_holidays.py
@@ -117,7 +117,10 @@ class hr_holidays(osv.osv):
},
}
- def _employee_get(self, cr, uid, context=None):
+ def _employee_get(self, cr, uid, context=None):
+ emp_id = context.get('default_employee_id', False)
+ if emp_id:
+ return emp_id
ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
if ids:
return ids[0]
@@ -204,9 +207,9 @@ class hr_holidays(osv.osv):
leave_ids = obj_res_leave.search(cr, uid, [('holiday_id', 'in', ids)], context=context)
return obj_res_leave.unlink(cr, uid, leave_ids, context=context)
- def onchange_type(self, cr, uid, ids, holiday_type):
- result = {'value': {'employee_id': False}}
- if holiday_type == 'employee':
+ def onchange_type(self, cr, uid, ids, holiday_type, employee_id):
+ result = {}
+ if holiday_type == 'employee' and not employee_id:
ids_employee = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
if ids_employee:
result['value'] = {
diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml
index f8b4ad07b77..041094c5999 100644
--- a/addons/hr_holidays/hr_holidays_view.xml
+++ b/addons/hr_holidays/hr_holidays_view.xml
@@ -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, employee_id)" 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')]}" 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>