Merge lp:~fabien-morin/unifield-server/fm-us-2856 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4386
Proposed branch: lp:~fabien-morin/unifield-server/fm-us-2856
Merge into: lp:unifield-server
Diff against target: 39 lines (+18/-1)
1 file modified
bin/addons/hr/hr_department.py (+18/-1)
To merge this branch: bzr merge lp:~fabien-morin/unifield-server/fm-us-2856
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+323897@code.launchpad.net
To post a comment you must log in.
Revision history for this message
jftempo (jfb-tempo-consulting) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/hr/hr_department.py'
2--- bin/addons/hr/hr_department.py 2017-02-20 10:01:21 +0000
3+++ bin/addons/hr/hr_department.py 2017-05-12 14:11:44 +0000
4@@ -41,10 +41,25 @@
5 res = self.name_get(cr, uid, ids, context=context)
6 return dict(res)
7
8+ def _get_ids_to_update(self, cr, uid, ids, context=None):
9+ '''
10+ recursive method to get all hr.department ids which have ancestor
11+ related to ids
12+ '''
13+ child_ids = self.search(cr, uid, [('parent_id', 'in', ids)], context=context)
14+ sub_child_ids = []
15+ if child_ids:
16+ sub_child_ids = self._get_ids_to_update(cr, uid, child_ids, context=context)
17+ return ids + sub_child_ids
18+
19 _name = "hr.department"
20 _columns = {
21 'name': fields.char('Department Name', size=64, required=True),
22- 'complete_name': fields.function(_dept_name_get_fnc, method=True, type="char", string='Name'),
23+ 'complete_name': fields.function(_dept_name_get_fnc, method=True,
24+ type="char", string='Name', size=512,
25+ store = {
26+ 'hr.department': (_get_ids_to_update, ['child_ids', 'name'], 10),
27+ }),
28 'company_id': fields.many2one('res.company', 'Company', select=True, required=False),
29 'parent_id': fields.many2one('hr.department', 'Parent Department', select=True),
30 'child_ids': fields.one2many('hr.department', 'parent_id', 'Child Departments'),
31@@ -55,6 +70,8 @@
32 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'hr.department', context=c),
33 }
34
35+ _order = 'complete_name, name, id'
36+
37 def _get_members(self, cr, uid, context=None):
38 mids = self.search(cr, uid, [('manager_id', '=', uid)], context=context)
39 result = {uid: 1}

Subscribers

People subscribed via source and target branches