~fabien-morin/unifield-web/fm-us-2925

« back to all changes in this revision

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

  • Committer: jf
  • Date: 2017-05-18 09:55:05 UTC
  • mfrom: (4842.3.5 unifield-web)
  • Revision ID: jfb@tempo-consulting.fr-20170518095505-as0f6t5pzap6edpo
US-2704 [IMP] Finance Dashbord: new attribute target_action_id on dashbord top open specific views

lp:~fabien-morin/unifield-web/fm-us-2704

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#  Developed by OpenERP (http://openerp.com) and Axelor (http://axelor.com).
8
8
#
9
9
#  The OpenERP web client is distributed under the "OpenERP Public License".
10
 
#  It's based on Mozilla Public License Version (MPL) 1.1 with following 
 
10
#  It's based on Mozilla Public License Version (MPL) 1.1 with following
11
11
#  restrictions:
12
12
#
13
13
#  -   All names, links and logos of OpenERP must be kept as in original
47
47
        ids = params.ids or []
48
48
 
49
49
        model = params.parent.model
 
50
        dashboard = False
 
51
        if model == 'board.board':
 
52
            dashboard = True
 
53
            model = params.model
50
54
        if model != params.model and not params.parent.id:
51
55
            error = _("Parent record doesn't exists...")
52
56
 
70
74
                if '__id' in data: data.pop('__id')
71
75
                if 'id' in data: data.pop('id')
72
76
 
73
 
                fld = source.split('/')[-1]
74
 
                data = {fld : [(id and 1, id, data.copy())]}
75
 
                proxy.write([params.parent.id], data, ctx)
 
77
                if not dashboard:
 
78
                    fld = source.split('/')[-1]
 
79
                    data = {fld : [(id and 1, id, data.copy())]}
 
80
                    proxy.write([params.parent.id], data, ctx)
 
81
                else:
 
82
                    data = data.copy()
 
83
                    proxy.write([id], data, ctx)
76
84
 
77
85
                if not id:
78
86
                    all_ids = proxy.read([params.parent.id], [fld])[0][fld]
81
89
                    ids = all_ids
82
90
                    if new_ids:
83
91
                        id = new_ids[0]
84
 
 
85
92
            else:
86
93
                data = frm.copy()
87
94
                if 'id' in data: data.pop('id')
103
110
    @expose('json', methods=('POST',))
104
111
    def remove(self, **kw):
105
112
        params, data = TinyDict.split(kw)
106
 
        sc_ids = [i['id'] for i in cherrypy.session['terp_shortcuts']]
107
113
        error = None
108
114
        proxy = rpc.RPCProxy(params.model)
109
115
        if params.id:
117
123
            try:
118
124
                ctx = context_with_concurrency_info(params.context, params.concurrency_info)
119
125
                if isinstance(params.id, list):
120
 
                    res = proxy.unlink(params.id, ctx)
 
126
                    proxy.unlink(params.id, ctx)
121
127
                    for i in params.id:
122
128
                        params.ids.remove(i)
123
129
                else:
124
 
                    res = proxy.unlink([params.id], ctx)
 
130
                    proxy.unlink([params.id], ctx)
125
131
                    params.ids.remove(params.id)
126
132
 
127
133
                if params.model == 'res.request':
225
231
            params.ids = None
226
232
        from view_graph.widgets import _graph
227
233
        wid = _graph.Graph(model=params.model,
228
 
              view=view,
229
 
              view_id=params.view_id,
230
 
              ids=params.ids, domain=params.domain,
231
 
              view_mode = params.view_mode,
232
 
              context=params.context,
233
 
              group_by = params.group_by_ctx)
 
234
                           view=view,
 
235
                           view_id=params.view_id,
 
236
                           ids=params.ids, domain=params.domain,
 
237
                           view_mode = params.view_mode,
 
238
                           context=params.context,
 
239
                           group_by = params.group_by_ctx)
234
240
        view=ustr(wid.render())
235
241
        return dict(view = view)
236
242
 
331
337
    @expose('json')
332
338
    def button_action(self, **kw):
333
339
        params, data = TinyDict.split(kw)
334
 
        error = None
335
 
        reload = (params.context or {}).get('reload', False)
336
 
        result = {}
337
340
 
338
341
        name = params.button_name
339
342
        btype = params.button_type
443
446
 
444
447
        total = []
445
448
        for field in sum_fields:
446
 
           total.append([])
 
449
            total.append([])
447
450
 
448
451
        for i in range(len(selected_ids)):
449
452
            for k in range(len(sum_fields)):
520
523
            return dict(error=str(e))
521
524
 
522
525
# vim: ts=4 sts=4 sw=4 si et
523