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

Proposed by jftempo on 2017-10-26
Status: Merged
Merged at revision: 4878
Proposed branch: lp:~jfb-tempo-consulting/unifield-web/jfb-int
Merge into: lp:unifield-web
Diff against target: 803 lines (+307/-50)
26 files modified
addons/openerp/controllers/__init__.py (+1/-0)
addons/openerp/controllers/actions.py (+4/-2)
addons/openerp/controllers/form.py (+2/-1)
addons/openerp/controllers/impex.py (+2/-2)
addons/openerp/controllers/search.py (+5/-2)
addons/openerp/controllers/shortcut_tooltip.py (+33/-0)
addons/openerp/controllers/templates/base.mako (+9/-9)
addons/openerp/controllers/templates/exp.mako (+1/-1)
addons/openerp/controllers/templates/form.mako (+18/-4)
addons/openerp/controllers/templates/header.mako (+1/-5)
addons/openerp/controllers/templates/imp.mako (+2/-1)
addons/openerp/controllers/templates/index.mako (+3/-0)
addons/openerp/controllers/templates/preferences/index.mako (+1/-1)
addons/openerp/controllers/templates/shortcut_tooltip.mako (+13/-0)
addons/openerp/po/javascript/fr.po (+4/-0)
addons/openerp/po/messages/fr.po (+4/-0)
addons/openerp/static/css/screen.css (+10/-0)
addons/openerp/static/css/tips.css (+19/-0)
addons/openerp/static/javascript/form.js (+43/-6)
addons/openerp/static/javascript/form_state.js (+14/-7)
addons/openerp/static/javascript/listgrid.js (+2/-2)
addons/openerp/static/javascript/m2m.js (+3/-1)
addons/openerp/static/javascript/m2o.js (+4/-2)
addons/openerp/static/javascript/o2m.js (+7/-1)
addons/openerp/static/javascript/openerp/openerp.base.js (+2/-1)
addons/openerp/static/javascript/web_keyboard_shortcuts.js (+100/-2)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-web/jfb-int
Reviewer Review Type Date Requested Status
UniField Dev Team 2017-10-26 Pending
Review via email: mp+332850@code.launchpad.net
To post a comment you must log in.
4872. By jftempo on 2017-10-27

US-2937 [IMP] JS code optimization

lp:~alexaubin/unifield-web/US-2937

4873. By jftempo on 2017-10-27

US-3589 [FIX] ir.ui.menu bug

lp:~alexaubin/unifield-web/US-3589-fix-ir-ui-menu

4874. By jftempo on 2017-10-27

US-2923 [FIX] account.mcdb: don't store the 'original domain' when searching for an existing query as it would lead to an inconsistent SQL request

lp:~julie-w/unifield-web/US-2923

4875. By jftempo on 2017-10-27

US-3211 [FIX] Error message on field validation

lp:~alexaubin/unifield-web/US-3211

4876. By jftempo on 2017-10-27

US-3381 [IMP] New attribute auto_refresh on tree view to auto reload page

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

4877. By jftempo on 2017-10-27

US-3172 [IMP] Keyboard shortcuts: popup help

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

4878. By jftempo on 2017-10-27

US-2310 [FIX] Standard Import: keep context

lp:~julie-w/unifield-web/US-2310

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/__init__.py'
2--- addons/openerp/controllers/__init__.py 2017-06-19 14:54:07 +0000
3+++ addons/openerp/controllers/__init__.py 2017-10-27 15:15:39 +0000
4@@ -16,6 +16,7 @@
5 import selection
6 import shortcuts
7 import banner
8+import shortcut_tooltip
9 import requests
10 import unifield_version
11 import openm2o
12
13=== modified file 'addons/openerp/controllers/actions.py'
14--- addons/openerp/controllers/actions.py 2017-05-16 12:26:11 +0000
15+++ addons/openerp/controllers/actions.py 2017-10-27 15:15:39 +0000
16@@ -65,7 +65,7 @@
17 def execute_window(view_ids, model, res_id=False, domain=None, view_type='form', context=None,
18 mode='form,tree', name=None, target=None, limit=None, search_view=None,
19 context_menu=False, display_menu_tip=False, action_id=None,
20- sidebar_open=False):
21+ sidebar_open=False, auto_refresh=False):
22 """Performs `actions.act_window` action.
23
24 @param view_ids: view ids
25@@ -93,6 +93,7 @@
26 params['display_menu_tip'] = display_menu_tip
27 params['sidebar_open'] = sidebar_open
28 params['target'] = target or None
29+ params['auto_refresh'] = auto_refresh
30 cherrypy.request._terp_view_name = name or None
31 cherrypy.request._terp_view_target = target or None
32
33@@ -367,7 +368,8 @@
34 context_menu=data.get('context_menu'),
35 display_menu_tip=display_menu_tip,
36 action_id=action.get('id'),
37- sidebar_open=action.get('sidebar_open'))
38+ sidebar_open=action.get('sidebar_open'),
39+ auto_refresh=action.get('auto_refresh'))
40
41 def server(action, data):
42 context = dict(data.get('context', {}),
43
44=== modified file 'addons/openerp/controllers/form.py'
45--- addons/openerp/controllers/form.py 2017-05-18 12:24:22 +0000
46+++ addons/openerp/controllers/form.py 2017-10-27 15:15:39 +0000
47@@ -273,7 +273,8 @@
48 tips = tips
49
50 is_dashboard = form.screen.is_dashboard or False
51- return dict(form=form, pager=pager, buttons=buttons, path=self.path, can_shortcut=can_shortcut, shortcut_ids=shortcut_ids, display_name=display_name, title=title, tips=tips, obj_process=obj_process, is_dashboard=is_dashboard, sidebar_closed=params._terp_sidebar_closed, sidebar_open=params.sidebar_open)
52+
53+ return dict(form=form, pager=pager, buttons=buttons, path=self.path, can_shortcut=can_shortcut, shortcut_ids=shortcut_ids, display_name=display_name, title=title, tips=tips, obj_process=obj_process, is_dashboard=is_dashboard, sidebar_closed=params._terp_sidebar_closed, sidebar_open=params.sidebar_open, auto_refresh=params.auto_refresh, tg_errors=tg_errors)
54
55 @expose('json', methods=('POST',))
56 def close_or_disable_tips(self):
57
58=== modified file 'addons/openerp/controllers/impex.py'
59--- addons/openerp/controllers/impex.py 2017-01-02 14:59:00 +0000
60+++ addons/openerp/controllers/impex.py 2017-10-27 15:15:39 +0000
61@@ -457,7 +457,7 @@
62 tree.show_headers = False
63 return dict(error=error, records=records, success=success,
64 model=params.model, source=params.source,
65- tree=tree, fields=kw.get('fields', {}))
66+ tree=tree, fields=kw.get('fields', {}), ctx=ctx)
67
68 @expose()
69 def detect_data(self, csvfile, csvsep, csvdel, csvcode, csvskip, **kw):
70@@ -566,7 +566,7 @@
71 **kw)
72
73 datas = []
74- ctx = dict(rpc.session.context)
75+ ctx = dict((params.context or {}), **rpc.session.context)
76
77 if not isinstance(fields, list):
78 fields = [fields]
79
80=== modified file 'addons/openerp/controllers/search.py'
81--- addons/openerp/controllers/search.py 2017-02-10 08:28:16 +0000
82+++ addons/openerp/controllers/search.py 2017-10-27 15:15:39 +0000
83@@ -398,8 +398,11 @@
84 ncustom_domain = openobject.i18n.format.convert_date_format_in_domain(ncustom_domain, res, context)
85
86 # (US-1360) Get the original domain used, convert it from String to List, and store it in the context
87- original_domain = all_domains.get('original_domain') and expr_eval(all_domains.get('original_domain')) or []
88- ctx.update({'original_domain': original_domain})
89+ if model != 'account.mcdb':
90+ # US-2923 When searching for a Saved query in the Selectors don't store the original_domain, otherwise it
91+ # would later be used on the account.analytic.lines/account.move.lines and lead to an inconsistent SQL request
92+ original_domain = all_domains.get('original_domain') and expr_eval(all_domains.get('original_domain')) or []
93+ ctx.update({'original_domain': original_domain})
94
95 return dict(domain=ustr(domain), context=ustr(ctx), search_data=ustr(search_data), filter_domain=ustr(ncustom_domain))
96
97
98=== added file 'addons/openerp/controllers/shortcut_tooltip.py'
99--- addons/openerp/controllers/shortcut_tooltip.py 1970-01-01 00:00:00 +0000
100+++ addons/openerp/controllers/shortcut_tooltip.py 2017-10-27 15:15:39 +0000
101@@ -0,0 +1,33 @@
102+###############################################################################
103+#
104+# Copyright (C) 2007-TODAY OpenERP SA. All Rights Reserved.
105+#
106+# $Id$
107+#
108+# Developed by OpenERP (http://openerp.com) and Axelor (http://axelor.com).
109+#
110+# The OpenERP web client is distributed under the "OpenERP Public License".
111+# It's based on Mozilla Public License Version (MPL) 1.1 with following
112+# restrictions:
113+#
114+# - All names, links and logos of OpenERP must be kept as in original
115+# distribution without any changes in all software screens, especially
116+# in start-up page and the software header, even if the application
117+# source code has been changed or updated or code has been added.
118+#
119+# You can see the MPL licence at: http://www.mozilla.org/MPL/MPL-1.1.html
120+#
121+###############################################################################
122+from openerp.controllers import SecuredController
123+from openerp.utils import rpc
124+
125+
126+class ShortcutTooltip(SecuredController):
127+
128+ _cp_path = "/openerp/shortcut_tooltip"
129+
130+ def get_show_shortcut(self):
131+ proxy = rpc.RPCProxy('sync.client.entity')
132+ return proxy.display_shortcut_message()
133+
134+# vim: ts=4 sts=4 sw=4 si et
135
136=== modified file 'addons/openerp/controllers/templates/base.mako'
137--- addons/openerp/controllers/templates/base.mako 2017-09-14 13:33:18 +0000
138+++ addons/openerp/controllers/templates/base.mako 2017-10-27 15:15:39 +0000
139@@ -1,31 +1,31 @@
140 <%inherit file="/openobject/controllers/templates/base.mako"/>
141
142 <%def name="header()">
143- <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.base.js?v=6.0"></script>
144+ <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.base.js?v=7.0"></script>
145 <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.ui.js"></script>
146 <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.ui.tips.js"></script>
147 <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.ui.waitbox.js"></script>
148 <script type="text/javascript" src="/openerp/static/javascript/openerp/openerp.ui.textarea.js"></script>
149
150 <script type="text/javascript" src="/openerp/static/javascript/scripts.js"></script>
151- <script type="text/javascript" src="/openerp/static/javascript/form.js?v=6.0"></script>
152+ <script type="text/javascript" src="/openerp/static/javascript/form.js?v=7.0"></script>
153 <script type="text/javascript" src="/openerp/static/javascript/form_state.js?v=2.3b2"></script>
154- <script type="text/javascript" src="/openerp/static/javascript/listgrid.js?v=2.8b1"></script>
155+ <script type="text/javascript" src="/openerp/static/javascript/listgrid.js?v=7.0"></script>
156
157- <script type="text/javascript" src="/openerp/static/javascript/m2o.js?v=2.6b4"></script>
158- <script type="text/javascript" src="/openerp/static/javascript/m2m.js"></script>
159- <script type="text/javascript" src="/openerp/static/javascript/o2m.js"></script>
160+ <script type="text/javascript" src="/openerp/static/javascript/m2o.js?v=7.0"></script>
161+ <script type="text/javascript" src="/openerp/static/javascript/m2m.js?v=7.0"></script>
162+ <script type="text/javascript" src="/openerp/static/javascript/o2m.js?v=7.0"></script>
163 <script type="text/javascript" src="/openerp/static/javascript/binary.js"></script>
164 <script type="text/javascript" src="/openerp/static/jscal/calendar.js"></script>
165 <script type="text/javascript" src="/openerp/static/jscal/calendar-setup.js"></script>
166
167- <script type="text/javascript" src="/openerp/static/javascript/web_keyboard_shortcuts.js"></script>
168+ <script type="text/javascript" src="/openerp/static/javascript/web_keyboard_shortcuts.js?v=7.0"></script>
169
170 <link rel="stylesheet" type="text/css" href="/openerp/static/css/style.css"/>
171 <link rel="stylesheet" type="text/css" href="/openerp/static/css/menu.css?v=2.7b1"/>
172- <link rel="stylesheet" type="text/css" href="/openerp/static/css/tips.css"/>
173+ <link rel="stylesheet" type="text/css" href="/openerp/static/css/tips.css?v=7.0"/>
174 <link rel="stylesheet" type="text/css" href="/openerp/static/css/waitbox.css"/>
175- <link rel="stylesheet" type="text/css" href="/openerp/static/css/screen.css?v=2.7b1"/>
176+ <link rel="stylesheet" type="text/css" href="/openerp/static/css/screen.css?v=7.0"/>
177
178 <link rel="stylesheet" type="text/css" href="/openerp/static/jscal/calendar-blue.css"/>
179 <link rel="stylesheet" type="text/css" href="/openerp/static/css/dashboard.css"/>
180
181=== modified file 'addons/openerp/controllers/templates/exp.mako'
182--- addons/openerp/controllers/templates/exp.mako 2017-08-29 09:33:08 +0000
183+++ addons/openerp/controllers/templates/exp.mako 2017-10-27 15:15:39 +0000
184@@ -286,7 +286,7 @@
185 <table width="100%">
186 <tr>
187 <td class="imp-header" align="right">
188- <a class="button-a" href="javascript: void(0)" onclick="window.frameElement.close()">${_("Cancel")}</a>
189+ <a class="button-a oe_form_button_cancel" href="javascript: void(0)" onclick="window.frameElement.close()">${_("Cancel")}</a>
190 <a class="button-a" href="javascript: void(0)" onclick="do_export('view_form')">${_("Export to File")}</a>
191 </td>
192 <td width="5%"></td>
193
194=== modified file 'addons/openerp/controllers/templates/form.mako'
195--- addons/openerp/controllers/templates/form.mako 2017-06-01 13:48:36 +0000
196+++ addons/openerp/controllers/templates/form.mako 2017-10-27 15:15:39 +0000
197@@ -25,6 +25,15 @@
198 /*
199 % endif
200 */
201+ /*
202+ % if auto_refresh :
203+ */
204+ setTimeout(function() {
205+ location.reload();
206+ }, ${auto_refresh}*1000);
207+ /*
208+ % endif
209+ */
210 setTimeout(function() {
211 jQuery('[autofocus="autofocus"]').focus();
212 }, 10);
213@@ -95,10 +104,10 @@
214 % endif
215
216 % if obj_process:
217- <a class="help" href="${py.url('/view_diagram/process', res_model=form.screen.model, title=form.screen.string, res_id=form.screen.id)}"
218- title="${_('Corporate Intelligence...')}">
219- <small>Help</small>
220- </a>
221+ <a class="help" href="${py.url('/view_diagram/process', res_model=form.screen.model, title=form.screen.string, res_id=form.screen.id)}"
222+ title="${_('Corporate Intelligence...')}">
223+ <small>Help</small>
224+ </a>
225 % endif
226 % if form.screen.view_type == 'form' and form.logs.logs:
227 <a id="show_server_logs" class="logs" href="javascript: void(0)"
228@@ -166,6 +175,7 @@
229 % if buttons.pager:
230 ${pager.display()}
231 % endif
232+
233 </div>
234 % endif
235 <div${ " class='non-editable'" if not form.screen.editable and form.screen.view_type == 'form' else "" | n }>${form.display()}</div>
236@@ -209,6 +219,10 @@
237 $hide.click();
238 return false;
239 })
240+
241+ % if tg_errors:
242+ error_display(_("The form contains errors."));
243+ % endif
244 })
245 </script>
246 </%def>
247
248=== modified file 'addons/openerp/controllers/templates/header.mako'
249--- addons/openerp/controllers/templates/header.mako 2016-06-14 16:01:53 +0000
250+++ addons/openerp/controllers/templates/header.mako 2017-10-27 15:15:39 +0000
251@@ -4,7 +4,6 @@
252 ROOT = cp.request.pool.get_controller("/openerp")
253 SHORTCUTS = cp.request.pool.get_controller("/openerp/shortcuts")
254 REQUESTS = cp.request.pool.get_controller("/openerp/requests")
255- UF_VERSION = cp.request.pool.get_controller("/openerp/unifield_version")
256
257 shortcuts = SHORTCUTS.my()
258 requests, total_request = REQUESTS.my()
259@@ -30,9 +29,6 @@
260 add_style = cp.config('server.environment') in css_style_dict.keys()
261 if add_style:
262 css_style = css_style_dict.get(cp.config('server.environment'), "")
263-
264-from openobject import release
265-version = release.version
266 %>
267 <td id="top"
268 % if add_style:
269@@ -153,6 +149,6 @@
270 src:this.href
271 }, null, {
272 height: 350
273- });
274+ }).focus();
275 });
276 </script>
277
278=== modified file 'addons/openerp/controllers/templates/imp.mako'
279--- addons/openerp/controllers/templates/imp.mako 2015-10-23 08:08:51 +0000
280+++ addons/openerp/controllers/templates/imp.mako 2017-10-27 15:15:39 +0000
281@@ -71,6 +71,7 @@
282 <input type="hidden" id="_terp_model" name="_terp_model" value="${model}"/>
283 <input type="hidden" id="_terp_ids" name="_terp_ids" value="[]"/>
284 <input type="hidden" id="_terp_fields2" name="_terp_fields2" value="[]"/>
285+ <input type="hidden" id="_terp_context" name="_terp_context" value="${ctx}"/>
286
287 <table class="view" cellspacing="5" border="0" width="100%">
288 <tr>
289@@ -202,7 +203,7 @@
290 <table width="100%">
291 <tr>
292 <td class="imp-header" align="left">
293- <a class="button-a" href="javascript: void(0)" onclick="window.frameElement.close()">${_("Close")}</a>
294+ <a class="button-a oe_form_button_cancel" href="javascript: void(0)" onclick="window.frameElement.close()">${_("Close")}</a>
295 <a class="button-a" href="javascript: void(0)" onclick="do_import();">${_("Import File")}</a>
296 </td>
297 <td width="5%"></td>
298
299=== modified file 'addons/openerp/controllers/templates/index.mako'
300--- addons/openerp/controllers/templates/index.mako 2017-06-19 14:54:07 +0000
301+++ addons/openerp/controllers/templates/index.mako 2017-10-27 15:15:39 +0000
302@@ -94,6 +94,9 @@
303 <tr>
304 <%include file="banner.mako"/>
305 </tr>
306+ <tr>
307+ <%include file="shortcut_tooltip.mako"/>
308+ </tr>
309 % if tools is not None:
310 <tr>
311 <td id="secondary" class="sidenav-open">
312
313=== modified file 'addons/openerp/controllers/templates/preferences/index.mako'
314--- addons/openerp/controllers/templates/preferences/index.mako 2016-11-21 09:45:23 +0000
315+++ addons/openerp/controllers/templates/preferences/index.mako 2017-10-27 15:15:39 +0000
316@@ -35,7 +35,7 @@
317 <button type='button' class="static_boxes"
318 onclick="open_password(); return false;"
319 >${_("Change Password")}</button>
320- <button type='button' class="static_boxes" onclick="window.frameElement.close();">${_("Cancel")}</button>
321+ <button type='button' class="static_boxes oe_form_button_cancel" onclick="window.frameElement.close();">${_("Cancel")}</button>
322 <button type='button' class="static_boxes" onclick="submit_form('ok');">${_("Save")}</button>
323 </td>
324 </tr>
325
326=== added file 'addons/openerp/controllers/templates/shortcut_tooltip.mako'
327--- addons/openerp/controllers/templates/shortcut_tooltip.mako 1970-01-01 00:00:00 +0000
328+++ addons/openerp/controllers/templates/shortcut_tooltip.mako 2017-10-27 15:15:39 +0000
329@@ -0,0 +1,13 @@
330+<%
331+# put in try block to prevent improper redirection on connection refuse error
332+try:
333+ SHORTCUT = cp.request.pool.get_controller("/openerp/shortcut_tooltip")
334+ display_message = SHORTCUT.get_show_shortcut()
335+ message = _("You haven't recently used a keyboard shortcut. You can see what shortcuts are available on this screen by holding SHIFT + CTRL.")
336+except:
337+ display_message = False
338+ message = 'toto'
339+%>
340+% if display_message:
341+<td id="shortcut_message" colspan="3">${message | h}</td>
342+% endif
343
344=== modified file 'addons/openerp/po/javascript/fr.po'
345--- addons/openerp/po/javascript/fr.po 2017-02-06 11:21:15 +0000
346+++ addons/openerp/po/javascript/fr.po 2017-10-27 15:15:39 +0000
347@@ -114,3 +114,7 @@
348 #: static/javascript/form.js
349 msgid "You cannot upload files bigger than %(max_size)sMB, current size is %(size)sMB"
350 msgstr "Vous ne pouvez pas envoyer des fichiers plus gros que %(max_size)sMB, la taille actuelle est de %(size)sMB"
351+
352+#: addons/openerp/controllers/templates/form.mako
353+msgid "The form contains errors."
354+msgstr "Le formulaire comporte des erreurs."
355
356=== modified file 'addons/openerp/po/messages/fr.po'
357--- addons/openerp/po/messages/fr.po 2017-01-02 14:59:00 +0000
358+++ addons/openerp/po/messages/fr.po 2017-10-27 15:15:39 +0000
359@@ -1775,3 +1775,7 @@
360 #~ msgid "Click here to add new image."
361 #~ msgstr "Cliquez ici pour ajouter une nouvelle image"
362
363+#: controllers/templates/shortcut_tooltip.mako:6
364+#, python-format
365+msgid "You haven't recently used a keyboard shortcut. You can see what shortcuts are available on this screen by holding SHIFT + CTRL."
366+msgstr "Vous n'avez pas utilisé de raccourci clavier récemment. Vous pouvez voir quels raccourcis sont disponibles sur cet écran en utilisant CTRL + SHIFT."
367
368=== modified file 'addons/openerp/static/css/screen.css'
369--- addons/openerp/static/css/screen.css 2017-07-10 08:56:45 +0000
370+++ addons/openerp/static/css/screen.css 2017-10-27 15:15:39 +0000
371@@ -2378,3 +2378,13 @@
372 background: rgba(255, 165, 0, .6);
373 white-space: pre-line;
374 }
375+
376+#shortcut_message {
377+ font-weight: bold;
378+ font-size: 1.2em;
379+ height: 2em;
380+ text-align: center;
381+ background: rgb(184, 222, 130);
382+ background: rgba(184, 222, 130, .6);
383+ white-space: pre-line;
384+}
385
386=== modified file 'addons/openerp/static/css/tips.css'
387--- addons/openerp/static/css/tips.css 2010-11-23 10:11:52 +0000
388+++ addons/openerp/static/css/tips.css 2017-10-27 15:15:39 +0000
389@@ -39,3 +39,22 @@
390 font-size: 12px;
391 }
392
393+
394+.shortcut_tooltip {
395+ padding: 4px;
396+ text-align: center;
397+ font-family: sans-serif;
398+ font-size: 11px;
399+ color: #666666;
400+ z-index: 1000;
401+ border-radius: 6px;
402+ -moz-border-radius: 6px;
403+ -webkit-border-radius: 6px;
404+ background: #FCF9A7;
405+ border: 1px solid #999;
406+ max-width: 500px;
407+ opacity: 1;
408+ -webkit-transition: opacity 1000ms linear;
409+ transition: opacity 1000ms linear;
410+ font-weight: bold;
411+}
412
413=== modified file 'addons/openerp/static/javascript/form.js'
414--- addons/openerp/static/javascript/form.js 2017-10-20 13:34:27 +0000
415+++ addons/openerp/static/javascript/form.js 2017-10-27 15:15:39 +0000
416@@ -97,6 +97,27 @@
417
418 var prefix = src && src != '_terp_list' ? src + '/' : '';
419
420+ // Here we do a sanity check that there aren't multiple element with
421+ // the same id 'prefix/_terp_model'
422+ // If this is the case, we introduce some delay (call back the same
423+ // function later)
424+ //
425+ // This can happen in some asynchronous edge-case where the DOM is not
426+ // fully loaded yet and in particular there's a remaining element with
427+ // _terp_model = ir.ui.menu
428+ // which might trigger the opening of a completely unrealted view
429+ //
430+ // You might reproduce the issue by monitoring the value of
431+ // openobject.dom.get(prefix + '_terp_model').value
432+ // when loading for instance the list of Commitment Vouchers
433+ //
434+ // See https://jira.unifield.org/browse/US-3589
435+ //
436+ if ($("[id="+prefix+"_terp_model]").length > 1) {
437+ callLater(0.1, openRecord, id, src, target, readonly);
438+ return;
439+ }
440+
441 var args = {
442 'model': openobject.dom.get(prefix + '_terp_model').value,
443 'id': id || 'False',
444@@ -255,11 +276,11 @@
445 }
446
447
448-function error_display(msg) {
449+function error_display(msg, title='Warning Message') {
450 var error = jQuery("<table>",{'width': '100%', 'height': '100%'}
451 ).append(
452 jQuery("<tr>").append(
453- jQuery("<td>", {'colspan': 2, 'class': 'error_message_header'}).text(_('Warning Message'))
454+ jQuery("<td>", {'colspan': 2, 'class': 'error_message_header'}).text(_(title))
455 ),
456 jQuery("<tr>").append(
457 jQuery("<td>", {'css': 'padding: 4px 2px;'}).append(
458@@ -275,7 +296,13 @@
459 .text('OK')
460 )
461 ));
462- window.top.jQuery.fancybox(error, {scrolling: 'no'});
463+ error.find('.button-a').focus()
464+ window.top.jQuery.fancybox(error, {
465+ scrolling: 'no',
466+ onComplete: function () {
467+ $(this).find(".button-a").focus()
468+ }
469+ });
470 }
471
472 function get_sidebar_status(args, noterp) {
473@@ -1022,7 +1049,18 @@
474 }
475
476 if (obj.error) {
477- return error_popup(obj.error)
478+ // 'TinyForm' error case : obj.error is a string
479+ if (obj.error_field) {
480+ // Retrieve the label associated to the label and display the
481+ // error
482+ var error_field_label = $('label[for="'+obj.error_field+'"]').text().trim()
483+ return error_display(error_field_label+" : "+obj.error);
484+ }
485+ // General exception case (no obj.error_field given)
486+ // obj.error is a full HTML page (and error_popup will display it)
487+ else {
488+ return error_popup(obj);
489+ }
490 }
491
492 return obj;
493@@ -1404,9 +1442,8 @@
494 dataType: 'json',
495 success: function(obj) {
496 if(obj.error) {
497- error_popup(obj.error);
498+ error_display(obj.error);
499 }
500-
501 $attachment_line.remove();
502 }
503 });
504
505=== modified file 'addons/openerp/static/javascript/form_state.js'
506--- addons/openerp/static/javascript/form_state.js 2017-10-19 14:33:30 +0000
507+++ addons/openerp/static/javascript/form_state.js 2017-10-27 15:15:39 +0000
508@@ -190,11 +190,19 @@
509 }
510
511 function list_hookAttrChange(list_name) {
512- jQuery('table[id='+list_name+'_grid] [attrs]').each(function () {
513- var $this = jQuery(this);
514+
515+ // check if an editor exists
516+ var editor_exists = $(".editors").length;
517+
518+ // Loop on list elements which have an 'attrs' attribute
519+ var listgrids = jQuery('table[id='+list_name+'_grid] [attrs]');
520+ for (var i = 0 ; i < listgrids.length ; i++)
521+ {
522+ var elem = listgrids[i];
523+ var $this = jQuery(elem);
524 var attrs = $this.attr('attrs') || '{}';
525 var widget = $this.attr('widget') || '';
526- var container = this;
527+ var container = elem;
528 var prefix = widget.slice(0, widget.lastIndexOf('/')+1) || '';
529
530 // Convert Python statement into it's equivalent in JavaScript.
531@@ -207,11 +215,9 @@
532 try {
533 attrs = eval('(' + attrs + ')');
534 } catch(e){
535- return;
536+ continue;
537 }
538
539- // check if an editor exists
540- var editor_exists = $(".editors").length;
541 var cache_values = {};
542
543 var row_is_editable = editor_exists && $this.parents('tr.grid-row').is('.editors');
544@@ -225,6 +231,7 @@
545 return form_onAttrChange(container, widget, attr, attrs[attr], $this, cache_values);
546 }
547 forEach(attrs[attr], function(n) {
548+
549 if (typeof(n) == "number") { // {'invisible': [1]}
550 return form_onAttrChange(container, widget, attr, n, $this, cache_values);
551 }
552@@ -237,7 +244,7 @@
553 return form_onAttrChange(container, widget, attr, attrs[attr], $this, cache_values);
554 });
555 }
556- });
557+ };
558 }
559
560 function form_onAttrChange(container, widgetName, attr, expr, elem, cache_values) {
561
562=== modified file 'addons/openerp/static/javascript/listgrid.js'
563--- addons/openerp/static/javascript/listgrid.js 2017-10-16 09:48:57 +0000
564+++ addons/openerp/static/javascript/listgrid.js 2017-10-27 15:15:39 +0000
565@@ -1155,7 +1155,7 @@
566 }, null, {
567 height: '98%',
568 max_height: 600
569- });
570+ }).focus();
571 },
572
573 importData: function() {
574@@ -1169,7 +1169,7 @@
575 height: '98%',
576 max_height: 550,
577 width: '95%'
578- });
579+ }).focus();
580 }
581 });
582
583
584=== modified file 'addons/openerp/static/javascript/m2m.js'
585--- addons/openerp/static/javascript/m2m.js 2017-01-02 14:59:00 +0000
586+++ addons/openerp/static/javascript/m2m.js 2017-10-27 15:15:39 +0000
587@@ -190,7 +190,7 @@
588 } else {
589 url = '/openerp/search/new';
590 }
591- return $.frame_dialog({
592+ var $frame = $.frame_dialog({
593 src: openobject.http.getURL(url, options)
594 }, {
595 'source-window': $this[0],
596@@ -199,6 +199,8 @@
597 width: '90%',
598 height: '95%'
599 });
600+ $frame.focus();
601+ return $frame;
602 }
603
604 /**
605
606=== modified file 'addons/openerp/static/javascript/m2o.js'
607--- addons/openerp/static/javascript/m2o.js 2017-06-01 13:48:36 +0000
608+++ addons/openerp/static/javascript/m2o.js 2017-10-27 15:15:39 +0000
609@@ -606,7 +606,7 @@
610 } else {
611 url = '/openerp/search/new';
612 }
613- return $.frame_dialog({
614+ var $frame = $.frame_dialog({
615 src: openobject.http.getURL(url, options)
616 }, {
617 'source-window': $this[0],
618@@ -616,6 +616,8 @@
619 max_width: 1200,
620 height: '95%'
621 });
622+ $frame.focus();
623+ return $frame;
624 }
625
626 /**
627@@ -681,7 +683,7 @@
628 if(arguments[0] === "close") {
629 return close($this, arguments[1]);
630 } else {
631- return open($this, arguments[0]);
632+ return open($this, arguments[0]).focus();
633 }
634 };
635 })(jQuery);
636
637=== modified file 'addons/openerp/static/javascript/o2m.js'
638--- addons/openerp/static/javascript/o2m.js 2017-10-20 13:34:27 +0000
639+++ addons/openerp/static/javascript/o2m.js 2017-10-27 15:15:39 +0000
640@@ -260,7 +260,13 @@
641 });
642 $frame.load(function() {
643 $frame_content = $frame.contents();
644- $frame_content.find("[autofocus='autofocus']").focus();
645+ if ($frame_content.find("[autofocus='autofocus']").lenght) {
646+ // if a field have an autofocus attribute, set the focus on it
647+ $frame_content.find("[autofocus='autofocus']").focus();
648+ }
649+ else {
650+ $frame.focus(); // set the focus on the whole frame
651+ }
652 });
653 var $form = jQuery('<form>', {
654 method: 'POST',
655
656=== modified file 'addons/openerp/static/javascript/openerp/openerp.base.js'
657--- addons/openerp/static/javascript/openerp/openerp.base.js 2017-10-17 09:38:02 +0000
658+++ addons/openerp/static/javascript/openerp/openerp.base.js 2017-10-27 15:15:39 +0000
659@@ -193,13 +193,14 @@
660 var $dialogs = jQuery('.action-dialog');
661 switch(target) {
662 case 'new':
663- jQuery.frame_dialog({
664+ $frame = jQuery.frame_dialog({
665 src: action_url,
666 'class': 'action-dialog'
667 }, null, {
668 width: '90%',
669 height: '95%'
670 });
671+ $frame.focus();
672 if (terp_id && !$dialogs.length) {
673 if (jQuery('#_terp_id').val() == 'False') {
674 // we are opening an action on an unsaved record,
675
676=== modified file 'addons/openerp/static/javascript/web_keyboard_shortcuts.js'
677--- addons/openerp/static/javascript/web_keyboard_shortcuts.js 2017-09-12 09:54:25 +0000
678+++ addons/openerp/static/javascript/web_keyboard_shortcuts.js 2017-10-27 15:15:39 +0000
679@@ -28,9 +28,107 @@
680
681 $.ctrlshift = function(key, callback, args) {
682 $(document).keydown(function(e) {
683+ if (e.ctrlKey && e.shiftKey) {
684+ var class_to_parse = null
685+ if (key == 'S'){
686+ class_to_parse = '.oe_form_button_save, .oe_form_button_save_line, .oe_form_button_save_close';
687+ }
688+ else if (key == 'E'){
689+ class_to_parse = '.oe_form_button_save_edit, .oe_form_button_edit';
690+ }
691+ else if (key == '46'){
692+ class_to_parse = '.oe_form_button_delete';
693+ }
694+ else if (key == 'Z'){
695+ class_to_parse = '.oe_form_button_cancel';
696+ }
697+ else if (key == 'C'){
698+ class_to_parse = '.oe_form_button_create, .oe_form_button_save_create';
699+ }
700+ else if (key == 'D'){
701+ class_to_parse = '.oe_form_button_duplicate';
702+ }
703+ else if (key == '13'){
704+ class_to_parse = '.oe_form_button_search';
705+ }
706+ else if (key == '38'){
707+ class_to_parse = '.oe_button_pager[action="first"]';
708+ }
709+ else if (key == '37'){
710+ class_to_parse = '.oe_button_pager[action="previous"]';
711+ }
712+ else if (key == '39'){
713+ class_to_parse = '.oe_button_pager[action="next"]';
714+ }
715+ else if (key == '40'){
716+ class_to_parse = '.oe_button_pager[action="last"]';
717+ }
718+ if (class_to_parse != null){
719+ //$('.oe_form_button_save')
720+ $(class_to_parse).each(function() {
721+
722+ // do not display tooltips on hidden notebook-page
723+ if ($(this).closest('.notebook-page').length && !$(this).closest('.notebook-page-active').length){
724+ console.log('notebook page not active');
725+
726+ }
727+ else {
728+ if (key == '46'){
729+ key_to_display = 'Del.'
730+ }
731+ else if (key == '13') {
732+ key_to_display = 'Enter&nbsp;&#8629;' // Enter
733+ //key_to_display = 'Enter' // Enter
734+ }
735+ else if (key == '38') {
736+ key_to_display = '&#8679;' // UP
737+ }
738+ else if (key == '37') {
739+ key_to_display = '&#8678;' // Left
740+ }
741+ else if (key == '39') {
742+ key_to_display = '&#8680;' // Right
743+ }
744+ else if (key == '40') {
745+ key_to_display = '&#8681;' // Down
746+ }
747+ else {
748+ key_to_display = key
749+ }
750+ if ($(this).width() == 0) {
751+ return false;
752+ }
753+ var $newdiv1 = $( "<span class='shortcut_tooltip'>" + key_to_display + "</span>" );
754+ $( "body" ).append($newdiv1);
755+ var postion = $(this).position();
756+ var new_top = postion.top + 20;
757+ if ($(this).width() <= 20){
758+ var new_left = postion.left - $newdiv1.width()/2;
759+ }
760+ else {
761+ var new_left = postion.left + $(this).width()/2 - $newdiv1.width()/2 + 6;
762+ }
763+ $newdiv1.css({top: new_top, left: new_left, position:'absolute'});
764+ setTimeout(function() {
765+ $newdiv1.css({'opacity': '0'});
766+ }, 1000);
767+
768+ setTimeout(function() {
769+ $newdiv1.remove();
770+ }, 2000);
771+ }
772+ });
773+ }
774+ }
775 if(!args) args=[]; // IE barks when args is null
776 if((e.keyCode == key.charCodeAt(0) || e.keyCode == key) && e.ctrlKey && e.shiftKey) {
777 e.preventDefault(); // override the browser shortcut keys
778+ if (!document.nb_shortcut_used){
779+ document.nb_shortcut_used = 1;
780+ }
781+ else{
782+ document.nb_shortcut_used += 1;
783+ }
784 callback.apply(this, args);
785 return false;
786 }
787@@ -132,14 +230,14 @@
788 });
789 });
790
791-//Previous object (arrow right)
792+//Previous object (arrow left)
793 $.ctrlshift('37', function() {
794 $('.oe_button_pager[action="previous"]').each(function() {
795 fake_click(this);
796 });
797 });
798
799-//Next object (arrow left)
800+//Next object (arrow right)
801 $.ctrlshift('39', function() {
802 $('.oe_button_pager[action="next"]').each(function() {
803 fake_click(this);

Subscribers

People subscribed via source and target branches