Merge lp:~openerp-dev/openerp-web/7.0-dynamic-counters-chm into lp:openerp-web/7.0

Proposed by Thibault Delavallée (OpenERP)
Status: Merged
Merged at revision: 3911
Proposed branch: lp:~openerp-dev/openerp-web/7.0-dynamic-counters-chm
Merge into: lp:openerp-web/7.0
Diff against target: 135 lines (+43/-6)
3 files modified
addons/web/static/src/js/chrome.js (+33/-4)
addons/web/static/src/js/view_form.js (+3/-0)
addons/web/static/src/js/views.js (+7/-2)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-dynamic-counters-chm
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+160884@code.launchpad.net
To post a comment you must log in.
3901. By Thibault Delavallée (OpenERP)

[MERGE] Sync with 7.à

3902. By Thibault Delavallée (OpenERP)

[MERGE] Sync with 7.0

3903. By Thibault Delavallée (OpenERP)

[REV] Removed code changed not related to this branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/chrome.js'
2--- addons/web/static/src/js/chrome.js 2013-04-18 12:56:40 +0000
3+++ addons/web/static/src/js/chrome.js 2013-04-26 07:58:26 +0000
4@@ -863,9 +863,7 @@
5 self.reflow();
6 // launch the fetch of needaction counters, asynchronous
7 if (!_.isEmpty(menu_data.all_menu_ids)) {
8- this.rpc("/web/menu/load_needaction", {menu_ids: menu_data.all_menu_ids}).done(function(r) {
9- self.on_needaction_loaded(r);
10- });
11+ this.do_load_needaction(menu_data.all_menu_ids);
12 }
13 });
14 var lazyreflow = _.debounce(this.reflow.bind(this), 200);
15@@ -891,7 +889,7 @@
16 this.data = {data: data};
17 this.renderElement();
18 this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
19- this.$el.on('click', 'a[data-menu]', this.on_menu_click);
20+ this.$el.on('click', 'a[data-menu]', this.on_top_menu_click);
21 // Hide second level submenus
22 this.$secondary_menus.find('.oe_menu_toggler').siblings('.oe_secondary_submenu').hide();
23 if (self.current_menu) {
24@@ -900,6 +898,12 @@
25 this.trigger('menu_loaded', data);
26 this.has_been_loaded.resolve();
27 },
28+ do_load_needaction: function (menu_ids) {
29+ var self = this;
30+ return this.rpc("/web/menu/load_needaction", {'menu_ids': menu_ids}).done(function(r) {
31+ self.on_needaction_loaded(r);
32+ });
33+ },
34 on_needaction_loaded: function(data) {
35 var self = this;
36 this.needaction_data = data;
37@@ -1031,11 +1035,36 @@
38 }
39 this.open_menu(id);
40 },
41+ do_reload_needaction: function () {
42+ var self = this;
43+ self.do_load_needaction([self.current_menu]).then(function () {
44+ self.trigger("need_action_reloaded");
45+ });
46+ },
47 /**
48 * Jquery event handler for menu click
49 *
50 * @param {Event} ev the jquery event
51 */
52+ on_top_menu_click: function(ev) {
53+ var self = this;
54+ var id = $(ev.currentTarget).data('menu');
55+ var menu_ids = [id];
56+ var menu = _.filter(this.data.data.children, function (menu) {return menu.id == id;})[0];
57+ function add_menu_ids (menu) {
58+ if (menu.children) {
59+ _.each(menu.children, function (menu) {
60+ menu_ids.push(menu.id);
61+ add_menu_ids(menu);
62+ });
63+ }
64+ };
65+ add_menu_ids(menu);
66+ self.do_load_needaction(menu_ids).then(function () {
67+ self.trigger("need_action_reloaded");
68+ });
69+ this.on_menu_click(ev);
70+ },
71 on_menu_click: function(ev) {
72 ev.preventDefault();
73 var needaction = $(ev.target).is('div.oe_menu_counter');
74
75=== modified file 'addons/web/static/src/js/view_form.js'
76--- addons/web/static/src/js/view_form.js 2013-04-11 16:32:38 +0000
77+++ addons/web/static/src/js/view_form.js 2013-04-26 07:58:26 +0000
78@@ -91,6 +91,7 @@
79 init: function(parent, dataset, view_id, options) {
80 var self = this;
81 this._super(parent);
82+ this.ViewManager = parent;
83 this.set_default_options(options);
84 this.dataset = dataset;
85 this.model = dataset.model;
86@@ -720,6 +721,8 @@
87 return this.save().done(function(result) {
88 self.trigger("save", result);
89 self.to_view_mode();
90+ }).then(function(result) {
91+ self.ViewManager.ActionManager.__parentedParent.menu.do_reload_needaction();
92 });
93 },
94 on_button_cancel: function(event) {
95
96=== modified file 'addons/web/static/src/js/views.js'
97--- addons/web/static/src/js/views.js 2013-03-22 16:23:10 +0000
98+++ addons/web/static/src/js/views.js 2013-04-26 07:58:26 +0000
99@@ -521,6 +521,7 @@
100 return x;
101 }
102 });
103+ this.ActionManager = parent;
104 this.views = {};
105 this.flags = flags || {};
106 this.registry = instance.web.views;
107@@ -1259,6 +1260,7 @@
108 view_type: undefined,
109 init: function(parent, dataset, view_id, options) {
110 this._super(parent);
111+ this.ViewManager = parent;
112 this.dataset = dataset;
113 this.view_id = view_id;
114 this.set_default_options(options);
115@@ -1330,7 +1332,6 @@
116 }
117 };
118 var context = new instance.web.CompoundContext(dataset.get_context(), action_data.context || {});
119-
120 var handler = function (action) {
121 if (action && action.constructor == Object) {
122 var ncontext = new instance.web.CompoundContext(context);
123@@ -1367,7 +1368,11 @@
124 }
125 }
126 args.push(context);
127- return dataset.call_button(action_data.name, args).then(handler);
128+ return dataset.call_button(action_data.name, args).then(handler).then(function () {
129+ if (self.ViewManager.ActionManager) {
130+ self.ViewManager.ActionManager.__parentedParent.menu.do_reload_needaction();
131+ }
132+ });
133 } else if (action_data.type=="action") {
134 return this.rpc('/web/action/load', {
135 action_id: action_data.name,