Merge lp:~jfb-tempo-consulting/unifield-web/US-2908 into lp:unifield-web

Proposed by jftempo
Status: Merged
Merged at revision: 4976
Proposed branch: lp:~jfb-tempo-consulting/unifield-web/US-2908
Merge into: lp:unifield-web
Diff against target: 53 lines (+24/-1)
1 file modified
addons/openerp/controllers/tree.py (+24/-1)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-web/US-2908
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+373886@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/tree.py'
2--- addons/openerp/controllers/tree.py 2018-10-30 10:57:51 +0000
3+++ addons/openerp/controllers/tree.py 2019-10-09 13:13:30 +0000
4@@ -145,13 +145,28 @@
5
6 return cmp(a, b)
7
8+ def return_item(self, element, fields):
9+ r = []
10+ for f in fields:
11+ r.append(element.get(f))
12+ return r
13+
14 @expose('json')
15 def data(self, ids, model, fields, field_parent=None, icon_name=None,
16- domain=[], context={}, sort_by=None, sort_order="asc", fields_info=None, colors={}, nolink=False):
17+ domain=None, context=None, sort_by=None, sort_order="asc", fields_info=None, colors=None, nolink=False):
18
19 if ids == 'None' or ids == '':
20 ids = []
21
22+ if domain is None:
23+ domain = []
24+
25+ if context is None:
26+ context = {}
27+
28+ if colors is None:
29+ colors = {}
30+
31 if isinstance(ids, basestring):
32 ids = map(int, ids.split(','))
33 elif isinstance(ids, list):
34@@ -186,11 +201,19 @@
35 if model == 'ir.ui.menu' and 'action' not in fields:
36 fields.append('action')
37
38+ if not sort_by and context.get('default_tree_sort'):
39+ sort_fields = context['default_tree_sort'].split(',')
40+ for f in sort_fields:
41+ if f not in fields:
42+ fields.append(f)
43+
44 result = proxy.read(ids, fields, ctx)
45
46 if sort_by:
47 fields_info_type = simplejson.loads(fields_info[sort_by])
48 result.sort(lambda a,b: self.sort_callback(a, b, sort_by, sort_order, type=fields_info_type['type']))
49+ elif context.get('default_tree_sort'):
50+ result = sorted(result, key=lambda item: self.return_item(item, sort_fields))
51
52 for item in result:
53 if colors:

Subscribers

People subscribed via source and target branches