0
나는 HR 관리자 인 모든 사용자가 레코드를 볼 수 있도록해야합니다. 기록 규칙에서레코드 규칙에서 기능 필드를 사용하는 방법은 무엇입니까?
<field name="always_true" invisible="1"/>
<field name="hr_managers_func" invisible="1"/>
: I 필드 'always_true'때문에 기록 규칙의 조건을 사용
['&','|',('state','=','hod_depart'),('state','=','hr_review'),('always_true','=',eval(hr_managers_func))]
.XML 파일에서
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
}
: 나는 기능이 필드를 만들었습니다 형식 즉, [('field_name', '연산자', 값)].
NameError: name 'eval' is not defined
내가 이것보다 더 생각하지 못했습니다 : 나는 규칙이 평가 를 사용하여 기능 분야를 평가하지만 불행히도 평가가 내가이 오류를 얻고, 기록 규칙에 작동하지 않는 생각했다. 나는 내 포럼과 다소 비슷한 몇 가지 포럼을 보았고 관련 필드를 사용하여 레코드의 기능 필드를 피했지만 현재 사용자가 hr 관리자인지 아닌지를 확인해야합니다. 나는 최선의 방법으로 이것을 설명하려고 노력했다.
대답이 완벽하게 작동하지만,이 경우에, 좋은 반응을 보내 람다 함수를 조정해야합니다 erppeek와 같은 도구를 사용하면 모든 기능 필드를 계산할 수 있습니다. fnct_search = _my_functional_field_search, type = 'boolean', 메서드는 = 'my_functional_field': fields.function (람다 셀, cr, uid, ID, 필드 이름, arg, 컨텍스트 = 없음 : dict.fromkeys (ids, 사실)' –