From 1dd8e54f6e46d64c9000cb3019c9197ba78a5555 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 8 Mar 2017 19:06:40 +0100 Subject: [PATCH] [ADD] Creation of BI view menu items --- bi_view_editor/README.rst | 1 + bi_view_editor/__init__.py | 1 + bi_view_editor/models/bve_view.py | 7 ++++ bi_view_editor/views/bve_view.xml | 1 + bi_view_editor/wizard/__init__.py | 5 +++ .../wizard/wizard_ir_model_menu_create.py | 32 +++++++++++++++++++ 6 files changed, 47 insertions(+) create mode 100644 bi_view_editor/wizard/__init__.py create mode 100644 bi_view_editor/wizard/wizard_ir_model_menu_create.py diff --git a/bi_view_editor/README.rst b/bi_view_editor/README.rst index f347a1b7..ae0daedb 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 d4da6d0f..2bd76b60 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 91e053bb..3e7c2d76 100644 --- a/bi_view_editor/models/bve_view.py +++ b/bi_view_editor/models/bve_view.py @@ -72,7 +72,14 @@ class BveView(models.Model): @api.multi def action_reset(self): self.ensure_one() + if self.action_id: + action = 'ir.actions.act_window,%d' % (self.action_id.id,) + menus = self.env['ir.ui.menu'].sudo().search( + [('action', '=', action)] + ) + menus.sudo().unlink() + if self.action_id.view_id: self.action_id.view_id.sudo().unlink() self.action_id.sudo().unlink() diff --git a/bi_view_editor/views/bve_view.xml b/bi_view_editor/views/bve_view.xml index 7152ad02..d6d50254 100644 --- a/bi_view_editor/views/bve_view.xml +++ b/bi_view_editor/views/bve_view.xml @@ -18,6 +18,7 @@