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
=== modified file 'addons/openerp/controllers/tree.py'
--- addons/openerp/controllers/tree.py 2018-10-30 10:57:51 +0000
+++ addons/openerp/controllers/tree.py 2019-10-09 13:13:30 +0000
@@ -145,13 +145,28 @@
145145
146 return cmp(a, b)146 return cmp(a, b)
147147
148 def return_item(self, element, fields):
149 r = []
150 for f in fields:
151 r.append(element.get(f))
152 return r
153
148 @expose('json')154 @expose('json')
149 def data(self, ids, model, fields, field_parent=None, icon_name=None,155 def data(self, ids, model, fields, field_parent=None, icon_name=None,
150 domain=[], context={}, sort_by=None, sort_order="asc", fields_info=None, colors={}, nolink=False):156 domain=None, context=None, sort_by=None, sort_order="asc", fields_info=None, colors=None, nolink=False):
151 157
152 if ids == 'None' or ids == '':158 if ids == 'None' or ids == '':
153 ids = []159 ids = []
154160
161 if domain is None:
162 domain = []
163
164 if context is None:
165 context = {}
166
167 if colors is None:
168 colors = {}
169
155 if isinstance(ids, basestring):170 if isinstance(ids, basestring):
156 ids = map(int, ids.split(','))171 ids = map(int, ids.split(','))
157 elif isinstance(ids, list):172 elif isinstance(ids, list):
@@ -186,11 +201,19 @@
186 if model == 'ir.ui.menu' and 'action' not in fields:201 if model == 'ir.ui.menu' and 'action' not in fields:
187 fields.append('action')202 fields.append('action')
188203
204 if not sort_by and context.get('default_tree_sort'):
205 sort_fields = context['default_tree_sort'].split(',')
206 for f in sort_fields:
207 if f not in fields:
208 fields.append(f)
209
189 result = proxy.read(ids, fields, ctx)210 result = proxy.read(ids, fields, ctx)
190211
191 if sort_by:212 if sort_by:
192 fields_info_type = simplejson.loads(fields_info[sort_by])213 fields_info_type = simplejson.loads(fields_info[sort_by])
193 result.sort(lambda a,b: self.sort_callback(a, b, sort_by, sort_order, type=fields_info_type['type']))214 result.sort(lambda a,b: self.sort_callback(a, b, sort_by, sort_order, type=fields_info_type['type']))
215 elif context.get('default_tree_sort'):
216 result = sorted(result, key=lambda item: self.return_item(item, sort_fields))
194217
195 for item in result:218 for item in result:
196 if colors:219 if colors:

Subscribers

People subscribed via source and target branches