summaryrefslogtreecommitdiff
path: root/odoo/addons/base/models/ir_module.py
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2020-01-31 14:11:36 +0000
committerYannick Tivisse <yti@odoo.com>2020-03-05 14:03:45 +0000
commit4c291e3f7049c3af859902a6f5857eab68be2f9e (patch)
treef05360b1d701cc921bedbf7d8df385838bd4bba2 /odoo/addons/base/models/ir_module.py
parent4f1fa7e24ce720167da4d1048edf8d6c13b4c520 (diff)
[IMP] base: Display searchpanel on ir.module.module views
Purpose ======= The current kanban view is messy. It is difficult to identify which apps are installed or not. The user can completely miss a module that might have interested him. A search panel would make things way more readable. closes odoo/odoo#44401 Taskid: 2181557 Related: odoo/enterprise#8144 Related: odoo/upgrade#879 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'odoo/addons/base/models/ir_module.py')
-rw-r--r--odoo/addons/base/models/ir_module.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py
index b10ca516f74..f042dd5aa7b 100644
--- a/odoo/addons/base/models/ir_module.py
+++ b/odoo/addons/base/models/ir_module.py
@@ -151,7 +151,7 @@ class Module(models.Model):
_name = "ir.module.module"
_rec_name = "shortdesc"
_description = "Module"
- _order = 'sequence,name'
+ _order = 'application desc,sequence,name'
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
@@ -907,6 +907,40 @@ class Module(models.Model):
for module in self.sudo().search([('state', '=', 'installed')])
}
+ @api.model
+ def search_panel_select_range(self, field_name):
+ if field_name == 'category_id':
+ domain = [('module_ids', '!=', False)]
+
+ excluded_xmlids = [
+ 'base.module_category_website_theme',
+ 'base.module_category_theme',
+ ]
+ if not self.user_has_groups('base.group_no_one'):
+ excluded_xmlids.append('base.module_category_hidden')
+
+ excluded_category_ids = []
+ for excluded_xmlid in excluded_xmlids:
+ categ = self.env.ref(excluded_xmlid, False)
+ if not categ:
+ continue
+ excluded_category_ids.append(categ.id)
+
+ if excluded_category_ids:
+ domain = expression.AND([domain, [
+ ('id', 'not in', excluded_category_ids),
+ ('parent_id', 'not in', excluded_category_ids),
+ ]])
+ categories = self.env['ir.module.category'].search(domain)
+ categories = categories | categories.mapped('parent_id')
+ return {
+ 'parent_field': 'parent_id',
+ 'values': self.env['ir.module.category'].search_read(
+ [('id', 'in', categories.ids)],
+ ['display_name', 'parent_id']),
+ }
+ return super(Module, self).search_panel_select_range(field_name)
+
DEP_STATES = STATES + [('unknown', 'Unknown')]