Browse Source

[ADD] Creation of BI view menu items

pull/59/head
Andrea 8 years ago
parent
commit
1dd8e54f6e
  1. 1
      bi_view_editor/README.rst
  2. 1
      bi_view_editor/__init__.py
  3. 7
      bi_view_editor/models/bve_view.py
  4. 1
      bi_view_editor/views/bve_view.xml
  5. 5
      bi_view_editor/wizard/__init__.py
  6. 32
      bi_view_editor/wizard/wizard_ir_model_menu_create.py

1
bi_view_editor/README.rst

@ -35,6 +35,7 @@ To graphically design your analysis data-set:
- Save and click "Generate BI View" - Save and click "Generate BI View"
- Click "Open BI View" to view the result - Click "Open BI View" to view the result
- If module Dashboard (board) is installed, the standard "Add to My Dashboard" functionality would be available - 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 .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot

1
bi_view_editor/__init__.py

@ -3,4 +3,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models
from . import wizard
from .hooks import uninstall_hook from .hooks import uninstall_hook

7
bi_view_editor/models/bve_view.py

@ -72,7 +72,14 @@ class BveView(models.Model):
@api.multi @api.multi
def action_reset(self): def action_reset(self):
self.ensure_one() self.ensure_one()
if self.action_id: 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: if self.action_id.view_id:
self.action_id.view_id.sudo().unlink() self.action_id.view_id.sudo().unlink()
self.action_id.sudo().unlink() self.action_id.sudo().unlink()

1
bi_view_editor/views/bve_view.xml

@ -18,6 +18,7 @@
<button name="action_reset" type="object" states="created" string="Reset to Draft"/> <button name="action_reset" type="object" states="created" string="Reset to Draft"/>
<button name="action_create" type="object" states="draft" string="Generate BI View" class="oe_highlight"/> <button name="action_create" type="object" states="draft" string="Generate BI View" class="oe_highlight"/>
<button name="open_view" type="object" states="created" string="Open BI View" class="oe_highlight"/> <button name="open_view" type="object" states="created" string="Open BI View" class="oe_highlight"/>
<button name="%(base.act_menu_create)d" type="action" states="created" groups="base.group_no_one" icon="fa-align-justify" string="Create a Menu" target="new"/>
<field name="state" widget="statusbar" statusbar_visible="draft,created" statusbar_colors='{"draft":"blue","created":"blue"}'/> <field name="state" widget="statusbar" statusbar_visible="draft,created" statusbar_colors='{"draft":"blue","created":"blue"}'/>
</header> </header>
<sheet> <sheet>

5
bi_view_editor/wizard/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import wizard_ir_model_menu_create

32
bi_view_editor/wizard/wizard_ir_model_menu_create.py

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp 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)
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,)
})
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
Loading…
Cancel
Save