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

Proposed by jftempo
Status: Merged
Merged at revision: 4948
Proposed branch: lp:~jfb-tempo-consulting/unifield-web/US-5330
Merge into: lp:unifield-web
Diff against target: 99 lines (+55/-1)
4 files modified
addons/openerp/controllers/form.py (+21/-0)
addons/openerp/controllers/view_log.py (+6/-0)
addons/openerp/static/javascript/form.js (+23/-0)
addons/openerp/widgets/templates/sidebar.mako (+5/-1)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-web/US-5330
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+361429@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/form.py'
2--- addons/openerp/controllers/form.py 2018-11-09 18:52:46 +0000
3+++ addons/openerp/controllers/form.py 2019-01-07 09:54:50 +0000
4@@ -293,6 +293,27 @@
5 return data_pool.read(data_ids[0], ['name'])['name']
6
7 @expose('json', methods=('POST',))
8+ def display_action_sd_ref(self, action_name, model, action_id):
9+ """
10+ Get sdref values of Button Access Rule and Model
11+ :param view_id: The ID of the ir.ui.view where the button is on
12+ :param btn_name: Name of the button to get values
13+ :param btn_model: Name (model) of the ir.model on which the button act
14+ :param btn_id: ID of the button
15+ """
16+
17+ action_win_pool = rpc.RPCProxy('ir.actions.act_window')
18+ data = action_win_pool.read([int(action_id)], ['groups_txt', 'type'])
19+ if not data:
20+ return False
21+ sdref = action_win_pool.get_sd_ref(action_id)
22+
23+ model_pool = rpc.RPCProxy('ir.model')
24+ model_id = model_pool.search([('model', '=', model)])
25+ model_sdref = model_pool.get_sd_ref(model_id[0])
26+ return dict(model=model, sdref=sdref, groups=data[0]['groups_txt'], model_sdref=model_sdref)
27+
28+ @expose('json', methods=('POST',))
29 def display_button_sd_ref(self, view_id, btn_name, btn_model, btn_id):
30 """
31 Get sdref values of Button Access Rule and Model
32
33=== modified file 'addons/openerp/controllers/view_log.py'
34--- addons/openerp/controllers/view_log.py 2018-08-14 12:34:13 +0000
35+++ addons/openerp/controllers/view_log.py 2019-01-07 09:54:50 +0000
36@@ -61,6 +61,12 @@
37 values['xmlid_code'] = xmlid[0]['xmlid_code']
38 fields.append(('xmlid_code', _('UniData xmlid_code')))
39
40+ if rpc.session.uid == 1:
41+ model_ids = rpc.session.execute('object', 'execute', 'ir.model', 'search', [('model', '=', model)])
42+ if model_ids:
43+ fields.insert(7, ('model_sdref', 'Model Sdref'))
44+ values['model_sdref'] = 'sd.%s' % rpc.session.execute('object', 'execute', 'ir.model', 'get_sd_ref', model_ids[0])
45+
46 return {'values':values, 'fields': fields}
47
48 # vim: ts=4 sts=4 sw=4 si et
49
50=== modified file 'addons/openerp/static/javascript/form.js'
51--- addons/openerp/static/javascript/form.js 2018-11-21 13:39:38 +0000
52+++ addons/openerp/static/javascript/form.js 2019-01-07 09:54:50 +0000
53@@ -21,6 +21,29 @@
54
55 var form_controller;
56
57+function showActionSdref(ev, action_name, model, action_id)
58+{
59+ if(ev.ctrlKey === true) {
60+
61+ openobject.http.postJSON('/openerp/form/display_action_sd_ref', {
62+ 'action_name': action_name,
63+ 'model': model,
64+ 'action_id': action_id,
65+ }).addCallback(function(obj){
66+ if (obj) {
67+ alert(
68+ 'Name : ' + action_name + '\n' +
69+ 'Action sdref: sd.' + obj.sdref + '\n' +
70+ 'Action Id: '+ action_id +'\n' +
71+ 'Groups: '+ obj.groups +'\n' +
72+ 'Model name: ' + model + '\n' +
73+ 'Model sdref: sd.'+ obj.model_sdref + '\n'
74+ );
75+ }
76+ });
77+ ev.preventDefault();
78+ }
79+}
80 function showBtnSdref(ev, btn_name, btn_model, btn_id, src)
81 {
82 if(ev.ctrlKey === true) {
83
84=== modified file 'addons/openerp/widgets/templates/sidebar.mako'
85--- addons/openerp/widgets/templates/sidebar.mako 2018-10-24 07:22:30 +0000
86+++ addons/openerp/widgets/templates/sidebar.mako 2019-01-07 09:54:50 +0000
87@@ -1,7 +1,11 @@
88 <%def name="sidebox_action_item(item, model, submenu, icon)">
89 % if submenu != 1:
90 <li action_id="${item['id']}" relation="${model}" domain="${item.get('domain')}" empty_ids="${item.get('empty_ids') and 1 or 0}"
91- context="${item.get('context')}" onclick="validate_action(this, do_action);">
92+ context="${item.get('context')}" onclick="validate_action(this, do_action);"
93+ % if rpc.session.uid == 1:
94+ oncontextmenu="showActionSdref(event, '${item['name']}', '${model}', '${item['id']}');"
95+ % endif
96+ >
97 % if icon:
98 <img src="${icon}" alt=""/>
99 % endif

Subscribers

People subscribed via source and target branches