3
0
Fork 0

[FIX] count needactions from the same model only once

10.0
Holger Brunn 2015-10-20 13:33:24 +02:00
parent fb000f2bf6
commit ae00081ee2
No known key found for this signature in database
GPG Key ID: 01C9760FECA3AE18
1 changed files with 11 additions and 6 deletions

View File

@ -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( count_per_model = {}
lambda x: x['needaction_counter'], for menu_id, needaction in self.search(
self.search([('id', 'child_of', this.ids)]) [('id', 'child_of', this.ids)])._filter_visible_menus()\
._filter_visible_menus().get_needaction_data() .get_needaction_data().iteritems():
.itervalues()) 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