=== modified file 'hr/hr.py' --- hr/hr.py 2010-09-11 13:29:00 +0000 +++ hr/hr.py 2010-10-02 18:25:50 +0000 @@ -132,18 +132,26 @@ } 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':{}} + if company: + 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}} + else: + return {'value':{'address_id':False}} def onchange_department(self, cr, uid, ids, department_id, context=None): - manager = self.pool.get('hr.department').browse(cr, uid, department_id).manager_id.id - return {'value': {'parent_id':manager or False}} + if department_id: + manager = self.pool.get('hr.department').browse(cr, uid, department_id).manager_id.id + return {'value': {'parent_id':manager or False}} + else: + return {'value': {'parent_id':False}} def onchange_user(self, cr, uid, ids, user_id, context=None): - mail = self.pool.get('res.users').browse(cr,uid,user_id) - return {'value': {'work_email':mail.user_email}} + if user_id: + mail = self.pool.get('res.users').browse(cr,uid,user_id) + return {'value': {'work_email':mail.user_email}} + else: + return {'value': {'work_email':False}} def _get_photo(self, cr, uid, context=None): return open(os.path.join( === modified file 'hr_evaluation/hr_evaluation.py' --- hr_evaluation/hr_evaluation.py 2010-09-22 07:05:07 +0000 +++ hr_evaluation/hr_evaluation.py 2010-10-02 18:12:04 +0000 @@ -114,13 +114,13 @@ obj_evaluation.create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id}, context=context) return True - def onchange_evaluation_plan_id(self, cr, uid, ids, evaluation_plan_id, evaluation_date, context=None): - evaluation_date = evaluation_date or False - evaluation_plan_obj=self.pool.get('hr_evaluation.plan') - obj_evaluation = self.pool.get('hr_evaluation.evaluation') + def onchange_evaluation_plan_id(self, cr, uid, ids, evaluation_plan_id, evaluation_date=False, context=None): if context is None: context = {} if evaluation_plan_id: + evaluation_plan_obj=self.pool.get('hr_evaluation.plan') + obj_evaluation = self.pool.get('hr_evaluation.evaluation') + flag = False evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id], context=context)[0] if not evaluation_date: @@ -192,11 +192,12 @@ return res def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): - employee_obj=self.pool.get('hr.employee') if context is None: context = {} - evaluation_plan_id='' + evaluation_plan_id=False if employee_id: + employee_obj=self.pool.get('hr.employee') + for employee in employee_obj.browse(cr, uid, [employee_id], context=context): if employee and employee.evaluation_plan_id and employee.evaluation_plan_id.id: evaluation_plan_id=employee.evaluation_plan_id.id === modified file 'hr_expense/hr_expense.py' --- hr_expense/hr_expense.py 2010-09-22 05:39:37 +0000 +++ hr_expense/hr_expense.py 2010-10-02 18:39:48 +0000 @@ -241,18 +241,18 @@ def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context=None): if context is None: context = {} - v = {} - if product_id: + res = {} + if product_id and employee_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 pricetype_id = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).user_id.company_id.property_valuation_price_type.id context['currency_id'] = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).user_id.company_id.currency_id.id pricetype = self.pool.get('product.price.type').browse(cr, uid, pricetype_id, context=context) amount_unit = product.price_get(pricetype.field, context)[product.id] - v['unit_amount'] = amount_unit + res['unit_amount'] = amount_unit if not uom_id: - v['uom_id'] = product.uom_id.id + res['uom_id'] = product.uom_id.id return {'value': v} hr_expense_line() === modified file 'hr_payroll/hr_payroll.py' --- hr_payroll/hr_payroll.py 2010-09-24 04:39:41 +0000 +++ hr_payroll/hr_payroll.py 2010-10-02 18:50:06 +0000 @@ -395,6 +395,9 @@ company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) if company.partner_id.bank_ids: res.update({'bank': company.partner_id.bank_ids[0].bank.name}) + else: + res.update({'bank':False}) + return { 'value':res } @@ -1211,8 +1214,7 @@ def onchange_category(self, cr, uid, ids, category_id): seq = 0 - res = { - } + res = {} if category_id: category = self.pool.get('hr.allounce.deduction.categoty').browse(cr, uid, category_id) res.update({ @@ -1221,14 +1223,21 @@ 'code':category.code, 'type':category.type }) + + else: + res.update({ + 'sequence':False, + 'name':False, + 'code':False, + 'type':False, + }) return {'value':res} - def onchange_amount(self, cr, uid, ids, amount, typ): - amt = amount - if typ and typ == 'per': - if int(amt) > 0: - amt = amt / 100 - return {'value':{'amount':amt}} + def onchange_amount(self, cr, uid, ids, amount, amount_type): + if amount_type and amount_type == 'per': + if int(amount) > 0: + amount = amount / 100 + return {'value':{'amount':amount}} _columns = { 'slip_id':fields.many2one('hr.payslip', 'Pay Slip', required=False), === modified file 'hr_recruitment/hr_recruitment.py' --- hr_recruitment/hr_recruitment.py 2010-09-22 05:39:37 +0000 +++ hr_recruitment/hr_recruitment.py 2010-10-02 18:52:34 +0000 @@ -181,15 +181,14 @@ } def onchange_job(self,cr, uid, ids, job, context=None): - job_obj = self.pool.get('hr.job') if context is None: context = {} result = {} - if job: + job_obj = self.pool.get('hr.job') result['department_id'] = job_obj.browse(cr, uid, job, context=context).department_id.id return {'value': result} - return {'value': {'department_id': []}} + return {'value': {'department_id': False}} def stage_previous(self, cr, uid, ids, context=None): """This function computes previous stage for case from its current stage