Browse Source

Merge pull request #243 from hbrunn/8.0-web_menu_navbar_needaction

[FIX] count needactions from the same model only once
pull/227/head
Pedro M. Baeza 9 years ago
parent
commit
c5f9f90024
  1. 1
      web_menu_navbar_needaction/__openerp__.py
  2. 17
      web_menu_navbar_needaction/models/ir_ui_menu.py
  3. 11
      web_menu_navbar_needaction/static/src/js/web_menu_navbar_needaction.js

1
web_menu_navbar_needaction/__openerp__.py

@ -26,6 +26,7 @@
"summary": "Show the sum of submenus' needaction counters in main menu", "summary": "Show the sum of submenus' needaction counters in main menu",
"depends": [ "depends": [
'web', 'web',
'mail',
], ],
"data": [ "data": [
"data/ir_config_parameter.xml", "data/ir_config_parameter.xml",

17
web_menu_navbar_needaction/models/ir_ui_menu.py

@ -27,10 +27,15 @@ class IrUiMenu(models.Model):
def get_navbar_needaction_data(self): def get_navbar_needaction_data(self):
result = {} result = {}
for this in self: for this in self:
result[this.id] = sum(map(
lambda x: x['needaction_counter'],
self.search([('id', 'child_of', this.ids)])
._filter_visible_menus().get_needaction_data()
.itervalues())
)
count_per_model = {}
for menu_id, needaction in self.search(
[('id', 'child_of', this.ids)])._filter_visible_menus()\
.get_needaction_data().iteritems():
if needaction['needaction_enabled']:
model = self.env['ir.ui.menu'].browse(menu_id).action\
.res_model
count_per_model[model] = max(
count_per_model.get(model),
needaction['needaction_counter'])
result[this.id] = sum(count_per_model.itervalues())
return result return result

11
web_menu_navbar_needaction/static/src/js/web_menu_navbar_needaction.js

@ -75,4 +75,15 @@ openerp.web_menu_navbar_needaction = function(instance)
}); });
}, },
}) })
instance.mail.Thread.include({
message_fetch_set_read: function (message_list)
{
this._super.apply(this, arguments);
return this.render_mutex.exec(function()
{
instance.client.menu.refresh_navbar_needaction();
});
},
})
} }
Loading…
Cancel
Save