[FIX] hr, hr_expense : On change event problem
lp bug: https://launchpad.net/bugs/653690 fixed bzr revid: skh@tinyerp.com-20101021122020-obeha6aimohkwmog
This commit is contained in:
parent
b3b0dd31d8
commit
340547a18e
|
@ -115,7 +115,7 @@ class hr_job(osv.osv):
|
|||
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}
|
||||
|
@ -165,23 +165,19 @@ class hr_employee(osv.osv):
|
|||
'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(
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<field name="company_id" widget="selection" groups="base.group_multi_company,base.group_extended" on_change="onchange_company(company_id)"/>
|
||||
<field name="active" groups="base.group_extended"/>
|
||||
<newline/>
|
||||
<field name="department_id" widget="selection" on_change="onchange_department(department_id)"/>
|
||||
<field name="department_id" widget="selection" />
|
||||
<field name="parent_id" />
|
||||
</group>
|
||||
<group colspan="2" col="1">
|
||||
|
|
|
@ -99,10 +99,10 @@ class hr_expense_expense(osv.osv):
|
|||
}
|
||||
|
||||
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, {
|
||||
|
@ -248,17 +248,17 @@ class hr_expense_line(osv.osv):
|
|||
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue