diff --git a/bi_view_editor/README.rst b/bi_view_editor/README.rst
index 19890b9d6..4c4f41eb5 100644
--- a/bi_view_editor/README.rst
+++ b/bi_view_editor/README.rst
@@ -35,6 +35,7 @@ To graphically design your analysis data-set:
- Save and click "Generate BI View"
- Click "Open BI View" to view the result
- If module Dashboard (board) is installed, the standard "Add to My Dashboard" functionality would be available
+- Click "Create a menu" to create a new menu item directly linked to your new BI view (this feature is available in developer mode)
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
diff --git a/bi_view_editor/__init__.py b/bi_view_editor/__init__.py
index d4da6d0f7..2bd76b602 100644
--- a/bi_view_editor/__init__.py
+++ b/bi_view_editor/__init__.py
@@ -3,4 +3,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
+from . import wizard
from .hooks import uninstall_hook
diff --git a/bi_view_editor/models/bve_view.py b/bi_view_editor/models/bve_view.py
index 4b90fe2a0..bdf16a6fb 100644
--- a/bi_view_editor/models/bve_view.py
+++ b/bi_view_editor/models/bve_view.py
@@ -374,7 +374,16 @@ class BveView(models.Model):
@api.multi
def action_reset(self):
self.ensure_one()
+
+ has_menus = False
if self.action_id:
+ action = 'ir.actions.act_window,%d' % (self.action_id.id,)
+ menus = self.env['ir.ui.menu'].sudo().search(
+ [('action', '=', action)]
+ )
+ has_menus = True if menus else False
+ menus.sudo().unlink()
+
if self.action_id.view_id:
self.action_id.view_id.sudo().unlink()
self.action_id.sudo().unlink()
@@ -389,6 +398,9 @@ class BveView(models.Model):
self.state = 'draft'
+ if has_menus:
+ return {'type': 'ir.actions.client', 'tag': 'reload'}
+
@api.multi
def unlink(self):
for view in self:
diff --git a/bi_view_editor/views/bve_view.xml b/bi_view_editor/views/bve_view.xml
index 7152ad02c..d6d50254d 100644
--- a/bi_view_editor/views/bve_view.xml
+++ b/bi_view_editor/views/bve_view.xml
@@ -18,6 +18,7 @@
+
diff --git a/bi_view_editor/wizard/__init__.py b/bi_view_editor/wizard/__init__.py
new file mode 100644
index 000000000..bca2d78f9
--- /dev/null
+++ b/bi_view_editor/wizard/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# Copyright 2017 Onestein ()
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from . import wizard_ir_model_menu_create
diff --git a/bi_view_editor/wizard/wizard_ir_model_menu_create.py b/bi_view_editor/wizard/wizard_ir_model_menu_create.py
new file mode 100644
index 000000000..58cc3288e
--- /dev/null
+++ b/bi_view_editor/wizard/wizard_ir_model_menu_create.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Copyright 2017 Onestein ()
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import api, models
+
+
+class WizardModelMenuCreate(models.TransientModel):
+ _inherit = 'wizard.ir.model.menu.create'
+
+ @api.multi
+ def menu_create(self):
+ if self._context.get('active_model') == 'bve.view':
+ self.ensure_one()
+ active_id = self._context.get('active_id')
+ bve_view = self.env['bve.view'].browse(active_id)
+ menu = self.env['ir.ui.menu'].create({
+ 'name': self.name,
+ 'parent_id': self.menu_id.id,
+ 'action': 'ir.actions.act_window,%d' % (bve_view.action_id,)
+ })
+ self.env['ir.model.data'].create({
+ 'name': bve_view.name + ', id=' + str(menu.id),
+ 'noupdate': True,
+ 'module': 'bi_view_editor',
+ 'model': 'ir.ui.menu',
+ 'res_id': menu.id,
+ })
+ return {'type': 'ir.actions.client', 'tag': 'reload'}
+ return super(WizardModelMenuCreate, self).menu_create()
+
+ @api.model
+ def default_get(self, fields_list):
+ defaults = super(WizardModelMenuCreate, self).default_get(fields_list)
+ if self._context.get('active_model') == 'bve.view':
+ active_id = self._context.get('active_id')
+ bve_view = self.env['bve.view'].browse(active_id)
+ defaults.setdefault('name', bve_view.name)
+ return defaults