Odoo中文网|Odoo实施培训
标题:
怎么在 domain 中使用函数字段
[打印本页]
作者:
非常感觉
时间:
2015-9-28 14:53
标题:
怎么在 domain 中使用函数字段
本帖最后由 非常感觉 于 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
作者:
非常感觉
时间:
2015-9-28 15:01
坐等大神帮忙。
作者:
美丽的大脚
时间:
2015-9-29 09:04
根据我的经验,函数字段 domain 和普通字段 domain 没有区别
欢迎光临 Odoo中文网|Odoo实施培训 (http://www.chinaodoo.net/)
Powered by Discuz! X3.2