~jfb-tempo-consulting/unifield-web/jfb-int

« back to all changes in this revision

Viewing changes to addons/openerp/controllers/listgrid.py

  • Committer: jf
  • Date: 2021-04-27 14:51:22 UTC
  • Revision ID: jfb@tempo-consulting.fr-20210427145122-k2rdmd5xh777flwo
2to3

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from openerp.utils import rpc, TinyDict, TinyForm, TinyFormError, context_with_concurrency_info, cache
27
27
from openerp.widgets import listgrid, listgroup
28
28
 
29
 
import form
30
 
import wizard
 
29
from . import form
 
30
from . import wizard
31
31
from openobject.tools import expose, ast
32
32
 
33
33
class List(SecuredController):
99
99
                    id = proxy.create(data, params.parent.context or {})
100
100
                    ids = [id] + ids
101
101
 
102
 
        except TinyFormError, e:
 
102
        except TinyFormError as e:
103
103
            error_field = e.field
104
104
            error = ustr(e)
105
 
        except Exception, e:
 
105
        except Exception as e:
106
106
            error = ustr(e)
107
107
 
108
108
        return dict(error_field=error_field, error=error, id=id, ids=str([int(i) for i in ids]))
135
135
                    return dict(res_ids = ids)
136
136
 
137
137
                return dict(ids = params.ids, count = len(params.ids))
138
 
            except Exception, e:
 
138
            except Exception as e:
139
139
                error = ustr(e)
140
140
 
141
141
        return dict(error=error)
220
220
            if isinstance(params.group_by_ctx, str):
221
221
                params.group_by_ctx = params.group_by_ctx.split('group_')[-1]
222
222
            else:
223
 
                params.group_by_ctx = map(lambda x: x.split('group_')[-1], params.group_by_ctx)
 
223
                params.group_by_ctx = [x.split('group_')[-1] for x in params.group_by_ctx]
224
224
 
225
225
        if params.domain is None:
226
226
            params.domain = []
244
244
        params, data = TinyDict.split(kw)
245
245
 
246
246
        groupby = params.get('_terp_group_by_ctx')
247
 
        if groupby and isinstance(groupby, basestring):
 
247
        if groupby and isinstance(groupby, str):
248
248
            groupby = groupby.split(',')
249
249
 
250
250
        if params.get('_terp_filters_context'):
267
267
 
268
268
        # clean defaults groupby if options available
269
269
        if params['_terp_search_data'] and params['_terp_search_data'].get('group_by_ctx',False):
270
 
            for k,v in params.context.items():
 
270
            for k,v in list(params.context.items()):
271
271
                if k.startswith('search_default') and k[15:] not in params['_terp_search_data'].get('group_by_ctx',{}):
272
272
                    del params['_terp_context'][k]
273
273
 
274
274
        if params.get('_terp_clear') or params.get('_terp_ids_to_show'):
275
275
            params.search_domain, params.filter_domain, params.ids = [], [], []
276
276
            params.search_data = {}
277
 
            for k,v in params.context.items():
 
277
            for k,v in list(params.context.items()):
278
278
                if k.startswith('search_default'):
279
279
                    del params.context[k]
280
280
 
359
359
            if btype == 'workflow':
360
360
                res = rpc.session.execute('object', 'exec_workflow', model, name, ids)
361
361
                if isinstance(res, dict):
362
 
                    import actions
 
362
                    from . import actions
363
363
                    return actions.execute(res, ids=ids)
364
364
                else:
365
365
                    return dict(reload=True, list_grid=list_grid)
373
373
                res = rpc.session.execute('object', 'execute', model, name, ids, ctx)
374
374
 
375
375
                if isinstance(res, dict):
376
 
                    import actions
 
376
                    from . import actions
377
377
                    return actions.execute(res, ids=ids)
378
378
                else:
379
379
                    return dict(reload=True, list_grid=list_grid)
380
380
 
381
381
            elif btype == 'action':
382
 
                import actions
 
382
                from . import actions
383
383
 
384
384
                action_id = int(name)
385
385
                action_type = actions.get_action_type(action_id)
401
401
 
402
402
            else:
403
403
                return dict(error = "Unallowed button type")
404
 
        except Exception, e:
 
404
        except Exception as e:
405
405
            return dict(error = ustr(e))
406
406
 
407
407
    @expose('json', methods=('POST',))
497
497
                proxy.write([prev_id], {'sequence': cur_seq}, ctx)
498
498
 
499
499
            return dict()
500
 
        except Exception, e:
 
500
        except Exception as e:
501
501
            return dict(error=str(e))
502
502
 
503
503
    @expose('json', methods=('POST',))
530
530
                proxy.write([next_id], {'sequence': cur_seq}, ctx)
531
531
 
532
532
            return dict()
533
 
        except Exception, e:
 
533
        except Exception as e:
534
534
            return dict(error=str(e))
535
535
 
536
536
# vim: ts=4 sts=4 sw=4 si et