'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(
- tools.config['addons_path'], 'hr/image', 'photo.png'),
- 'rb') .read().encode('base64')
+ paths = tools.config['addons_path'].split(",")
+ for path in paths:
+ full_path = os.path.join(path, 'hr/image', 'photo.png')
+ if os.path.exists(full_path):
+ return open(full_path,'rb') .read().encode('base64')
+ raise Exception("photo.png could not be found")
_defaults = {
'active': 1,