def on_change_expected_employee(self, cr, uid, ids, expected_employee, no_of_employee, context=None):
if context is None:
context = {}
- result={}
+ result = {}
if expected_employee:
result['no_of_recruitment'] = expected_employee - no_of_employee
return {'value': result}
'passport_id':fields.char('Passport', size=64)
}
- def onchange_company(self, cr, uid, ids, company, context=None):
- company_id = self.pool.get('res.company').browse(cr,uid,company)
- for address in company_id.partner_id.address:
- return {'value': {'address_id': address.id}}
- return {'value':{'address_id':False}}
-
- def onchange_department(self, cr, uid, ids, department_id, context=None):
- if not department_id:
- return {'value':{'parent_id': False}}
- manager = self.pool.get('hr.department').browse(cr, uid, department_id).manager_id
- return {'value': {'parent_id':manager and manager.id or False}}
+ def onchange_company(self, cr, uid, ids, company, context=None):
+ address_id = False
+ if company:
+ company_id = self.pool.get('res.company').browse(cr,uid,company)
+ address = self.pool.get('res.partner').address_get(cr, uid, [company_id.partner_id.id], ['default'])
+ address_id = address and address['default'] or False
+ return {'value': {'address_id' : address_id}}
def onchange_user(self, cr, uid, ids, user_id, context=None):
- if not user_id:
- return {'value':{'work_email': False}}
- mail = self.pool.get('res.users').browse(cr,uid,user_id)
- return {'value': {'work_email':mail.user_email}}
+ work_email = False
+ if user_id:
+ work_email = self.pool.get('res.users').browse(cr, uid, user_id).user_email
+ return {'value': {'work_email' : work_email}}
def _get_photo(self, cr, uid, context=None):
return open(os.path.join(
}
def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
- if not employee_id:
- return {'value':{'department_id': False}}
- dept = self.pool.get('hr.employee').browse(cr, uid, employee_id).department_id
- return {'value': {'department_id':dept and dept.id or False}}
+ department_id = False
+ if employee_id:
+ department_id = self.pool.get('hr.employee').browse(cr, uid, employee_id).department_id.id or False
+ return {'value':{'department_id':department_id}}
def expense_confirm(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context=None):
if context is None:
context = {}
- v = {}
+ res = {}
if product_id:
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
- v['name'] = product.name
+ res['name'] = product.name
# Compute based on pricetype of employee company
context['currency_id'] = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).user_id.company_id.currency_id.id
amount_unit = product.price_get('standard_price', context)[product.id]
- v['unit_amount'] = amount_unit
+ res['unit_amount'] = amount_unit
if not uom_id:
- v['uom_id'] = product.uom_id.id
- return {'value': v}
+ res['uom_id'] = product.uom_id.id
+ return {'value': res}
hr_expense_line()