|
本帖最后由 非常感觉 于 2015-9-28 15:00 编辑
我想实现,只有HR 经理才可以看到这些记录,我已经创建了函数字段:
- def list_HRM(self, cr, uid, ids, field_name, arg, context):
- attribute = {}
- hr_managers = self.pool.get('hr.employee').search(cr, uid, ['&', ('department_id.name', '=', 'Human Resources'), ('manager', '=', True)], context=context)
- hr_managers_uid = []
- for record in hr_managers:
- hr_managers_uid.append(self.pool.get('hr.employee').browse(cr, uid, record, context=context).user_id.id)
- record = self.browse(cr, uid, ids)[0]
- attribute[record.id] = str(uid in hr_managers_uid or uid==1)
- return attribute
- _columns={
- 'hr_managers_func' : fields.function(list_HRM, type='char', method=True, string='List of HR Managers'),
- 'always_true':fields.boolean()
- }
- _defaults={
- 'always_true':True
- }
复制代码
In .xml file:
- <field name="always_true" invisible="1"/>
- <field name="hr_managers_func" invisible="1"/>
复制代码
In Record Rule:
- ['&','|',('state','=','hod_depart'),('state','=','hr_review'),('always_true','=',eval(hr_managers_func))]
复制代码
运行的时候报错:
NameError: name 'eval' is not defined |
|