~jfb-tempo-consulting/unifield-web/US-7614

« back to all changes in this revision

Viewing changes to addons/openerp/widgets/listgroup.py

  • Committer: jf
  • Date: 2020-04-01 09:57:08 UTC
  • mfrom: (4987.3.1 unifield-web)
  • Revision ID: jfb@tempo-consulting.fr-20200401095708-0yiukc1ly17kqg5w
[MERGE] UF16.1rc1
    US-7304 [IMP] Replenishment Rules: formatting v2: new widget html_text

Show diffs side-by-side

added added

removed removed

Lines of Context:
226
226
 
227
227
        self.group_by_ctx, self.hiddens, self.headers = parse(self.group_by_ctx, self.hiddens, self.headers, None, self.group_by_ctx)
228
228
 
229
 
        self.grp_records = proxy.read_group(self.context.get('__domain', []) + (self.domain or []),
230
 
                                            fields.keys(), self.group_by_ctx, 0, False, self.context)
231
229
 
 
230
        limited_groupby = self.model == 'replenishment.product.list'
 
231
        order_by = ''
232
232
        terp_params = getattr(cherrypy.request, 'terp_params', [])
233
233
        if terp_params.sort_key and terp_params.sort_key in self.group_by_ctx and self.group_by_ctx.index(terp_params.sort_key) == 0:
 
234
            order_by = terp_params.sort_key
234
235
            if terp_params.sort_order == 'desc':
235
236
                rev = True
 
237
                order_by += ' desc'
236
238
            else:
237
239
                rev = False
 
240
                order_by += ' asc'
 
241
 
 
242
        read_offset = 0
 
243
        read_limit = False
 
244
        read_groupby = False
 
245
        if limited_groupby:
 
246
            read_offset = terp_offset
 
247
            read_limit = terp_limit
 
248
            read_groupby = order_by
 
249
            order_by = False
 
250
 
 
251
        self.grp_records = proxy.read_group(self.context.get('__domain', []) + (self.domain or []),
 
252
                                            fields.keys(), self.group_by_ctx, read_offset, read_limit, self.context, read_groupby)
 
253
 
 
254
        if order_by:
238
255
            self.grp_records = sorted(self.grp_records, key=itemgetter(terp_params.sort_key), reverse=rev)
239
 
 
240
256
        for grp_rec in self.grp_records:
241
257
            if not grp_rec.get('__domain'):
242
258
                grp_rec['__domain'] = self.context.get('__domain', []) + (self.domain or [])
246
262
        self.grouped, grp_ids = parse_groups(self.group_by_ctx, self.grp_records, self.headers, self.ids, model, terp_offset, terp_limit, self.context, self.data, self.field_total, fields, self.rounding_values)
247
263
 
248
264
        if self.pageable:
249
 
            self.count = len(self.grouped)
 
265
            if limited_groupby:
 
266
                self.count = proxy.read_group(self.context.get('__domain', []) + (self.domain or []), fields.keys(), self.group_by_ctx, 0, False, self.context, False, True)
 
267
            else:
 
268
                self.count = len(self.grouped)
 
269
 
250
270
            self.pager = Pager(ids=self.ids, offset=self.offset, limit=self.limit, count=self.count)
251
271
            self.pager._name = self.name
252
272
 
253
273
        # Display only the lines according to pager
254
 
        start_index = self.offset
255
 
        end_index = self.offset + self.limit
256
 
        self.grp_records = self.grp_records[start_index:end_index]
 
274
        if not limited_groupby:
 
275
            start_index = self.offset
 
276
            end_index = self.offset + self.limit
 
277
            self.grp_records = self.grp_records[start_index:end_index]
257
278
 
258
279
 
259
280
class MultipleGroup(List):