如何在报表中显示业务员的手机号码?
-
[quote][o.user_id.employee_ids and o.user_id.employee_ids[0].mobile_phone]
[o.user_id.employee_id and o.user_id.employee_id[0].mobile_phone]
[o.user_id.employee_ids and o.user_id.employee_ids.mobile_phone][/quote]
第一句的emplyee_ids是user_id里面的字段。
第二句employee_id不是一个字段。
第三句employee_ids[0]意思是取这个many2many2字段的第一个值。
所以这句正确写法是:[[o.user_id.employee_ids and o.user_id.employee_ids[0].mobile_phone]]
看了下6.1的代码,res.users模型里面并没有employee_ids字段,所以在6.1这样取值是不行的,你可以仿效7.0给res.users添加employee_ids字段
代码如下: _columns = {<br /> 'employee_ids': fields.one2many('hr.employee', 'user_id', 'Related employees'),<br /> }
-
恩,找到问题了;之前代码加错地方了
改完以后是这样的
class res_users(osv.osv):
_name = 'res.users'
_inherit = 'res.users'
def create(self, cr, uid, data, context=None):
user_id = super(res_users, self).create(cr, uid, data, context=context)
# add shortcut unless 'noshortcut' is True in context
if not(context and context.get('noshortcut', False)):
data_obj = self.pool.get('ir.model.data')
try:
data_id = data_obj._get_id(cr, uid, 'hr', 'ir_ui_view_sc_employee')
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
self.pool.get('ir.ui.view_sc').copy(cr, uid, view_id, default = {
'user_id': user_id}, context=context)
except:
# Tolerate a missing shortcut. See product/product.py for similar code.
logging.getLogger('orm').debug('Skipped meetings shortcut for user "%s"', data.get('name','<new'))
return user_id
_columns = {
'employee_ids': fields.one2many('hr.employee', 'user_id', 'Related employees'),
}
res_users()