diff options
| author | RomainLibert <rli@odoo.com> | 2019-04-02 11:06:08 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2019-05-31 10:21:20 +0200 |
| commit | d09d5c2e8af1b5c00b84c8961d8024e5cbfe76d3 (patch) | |
| tree | 10a8d41ae4e7c6a8d7a6c48ee72345dd10917e42 /addons/hr_org_chart/controllers | |
| parent | c9ca3761464413327d2beb697553a3ccd7eef4d1 (diff) | |
[IMP] hr_org_chart: Adapt module with new hr.employee.public model
Diffstat (limited to 'addons/hr_org_chart/controllers')
| -rw-r--r-- | addons/hr_org_chart/controllers/hr_org_chart.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/addons/hr_org_chart/controllers/hr_org_chart.py b/addons/hr_org_chart/controllers/hr_org_chart.py index 4a8fb029dda..d9aeb0ce5fa 100644 --- a/addons/hr_org_chart/controllers/hr_org_chart.py +++ b/addons/hr_org_chart/controllers/hr_org_chart.py @@ -19,7 +19,7 @@ class HrOrgChartController(http.Controller): else: cids = [request.env.company.id] - Employee = request.env['hr.employee'].with_context(allowed_company_ids=cids) + Employee = request.env['hr.employee.public'].with_context(allowed_company_ids=cids) # check and raise if not Employee.check_access_rights('read', raise_exception=False): return None @@ -35,13 +35,19 @@ class HrOrgChartController(http.Controller): return dict( id=employee.id, name=employee.name, - link='/mail/view?model=hr.employee&res_id=%s' % employee.id, + link='/mail/view?model=%s&res_id=%s' % ('hr.employee.public', employee.id,), job_id=job.id, job_name=job.name or '', direct_sub_count=len(employee.child_ids), indirect_sub_count=employee.child_all_count, ) + @http.route('/hr/get_redirect_model', type='json', auth='user') + def get_redirect_model(self): + if request.env['hr.employee'].check_access_rights('read', raise_exception=False): + return 'hr.employee' + return 'hr.employee.public' + @http.route('/hr/get_org_chart', type='json', auth='user') def get_org_chart(self, employee_id, **kw): @@ -50,7 +56,7 @@ class HrOrgChartController(http.Controller): return {} # compute employee data for org chart - ancestors, current = request.env['hr.employee'], employee + ancestors, current = request.env['hr.employee.public'], employee while current.parent_id and len(ancestors) < self._managers_level+1: ancestors += current.parent_id current = current.parent_id @@ -81,8 +87,10 @@ class HrOrgChartController(http.Controller): return {} if subordinates_type == 'direct': - return employee.child_ids.ids + res = employee.child_ids.ids elif subordinates_type == 'indirect': - return (employee.subordinate_ids - employee.child_ids).ids + res = (employee.subordinate_ids - employee.child_ids).ids else: - return employee.subordinate_ids.ids + res = employee.subordinate_ids.ids + + return res |
