Browse Source

bi_sql_editor

pull/264/head
nicomacr 7 years ago
committed by Adrià Gil Sorribes
parent
commit
2e64099ff0
  1. 2
      bi_sql_editor/README.rst
  2. 2
      bi_sql_editor/__openerp__.py
  3. 29
      bi_sql_editor/models/bi_sql_view.py
  4. 9
      bi_sql_editor/models/bi_sql_view_field.py
  5. 2
      bi_sql_editor/views/menu.xml
  6. 1
      bi_sql_editor/views/view_bi_sql_view.xml

2
bi_sql_editor/README.rst

@ -152,7 +152,7 @@ Contributors
* This module is highly inspired by the work of
* Onestein: (http://www.onestein.nl/)
Module: OCA/server-tools/bi_view_editor.
Link: https://github.com/OCA/reporting-engine/tree/8.0/bi_view_editor
Link: https://github.com/OCA/reporting-engine/tree/9.0/bi_view_editor
* Anybox: (https://anybox.fr/)
Module : OCA/server-tools/materialized_sql_view
link: https://github.com/OCA/server-tools/pull/110

2
bi_sql_editor/__openerp__.py

@ -6,7 +6,7 @@
{
'name': 'BI SQL Editor',
'summary': "BI Views builder, based on Materialized or Normal SQL Views",
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'license': 'AGPL-3',
'category': 'Reporting',
'author': 'GRAP,Odoo Community Association (OCA)',

29
bi_sql_editor/models/bi_sql_view.py

@ -89,6 +89,9 @@ class BiSQLView(models.Model):
graph_view_id = fields.Many2one(
string='Odoo Graph View', comodel_name='ir.ui.view', readonly=True)
pivot_view_id = fields.Many2one(
string='Odoo Pivot View', comodel_name='ir.ui.view', readonly=True)
search_view_id = fields.Many2one(
string='Odoo Search View', comodel_name='ir.ui.view', readonly=True)
@ -184,6 +187,7 @@ class BiSQLView(models.Model):
sql_view._drop_model_and_fields()
sql_view.graph_view_id.unlink()
sql_view.pivot_view_id.unlink()
sql_view.action_id.unlink()
sql_view.menu_id.unlink()
sql_view.rule_id.unlink()
@ -195,6 +199,8 @@ class BiSQLView(models.Model):
def button_create_ui(self):
self.graph_view_id = self.env['ir.ui.view'].create(
self._prepare_graph_view()).id
self.pivot_view_id = self.env['ir.ui.view'].create(
self._prepare_pivot_view()).id
self.search_view_id = self.env['ir.ui.view'].create(
self._prepare_search_view()).id
self.action_id = self.env['ir.actions.act_window'].create(
@ -218,10 +224,9 @@ class BiSQLView(models.Model):
return {
'type': 'ir.actions.act_window',
'res_model': self.model_id.model,
'view_id': self.graph_view_id.id,
'search_view_id': self.search_view_id.id,
'view_type': 'graph',
'view_mode': 'graph',
'view_type': 'form',
'view_mode': 'graph,pivot',
}
# Prepare Function
@ -292,6 +297,21 @@ class BiSQLView(models.Model):
for x in self.bi_sql_view_field_ids]))
}
@api.multi
def _prepare_pivot_view(self):
self.ensure_one()
return {
'name': self.name,
'type': 'pivot',
'model': self.model_id.model,
'arch':
"""<?xml version="1.0"?>"""
"""<pivot string="Analysis" stacked="True">{}"""
"""</pivot>""".format("".join(
[x._prepare_pivot_field()
for x in self.bi_sql_view_field_ids]))
}
@api.multi
def _prepare_search_view(self):
self.ensure_one()
@ -320,8 +340,7 @@ class BiSQLView(models.Model):
'res_model': self.model_id.model,
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'graph',
'view_id': self.graph_view_id.id,
'view_mode': 'graph,pivot',
'search_view_id': self.search_view_id.id,
}

9
bi_sql_editor/models/bi_sql_view_field.py

@ -175,6 +175,15 @@ class BiSQLViewField(models.Model):
self.name, self.graph_type)
return res
@api.multi
def _prepare_pivot_field(self):
self.ensure_one()
res = ''
if self.graph_type and self.field_description:
res = """<field name="{}" type="{}" />""".format(
self.name, self.graph_type)
return res
@api.multi
def _prepare_search_field(self):
self.ensure_one()

2
bi_sql_editor/views/menu.xml

@ -10,7 +10,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<!-- Menu that will contain all the SQL report generated by this module -->
<menuitem id="menu_bi_sql_editor"
name="SQL Reports"
parent="base.menu_reporting"
parent="base.menu_board_root"
sequence="0"/>
<menuitem id="menu_bi_sql_view"

1
bi_sql_editor/views/view_bi_sql_view.xml

@ -111,6 +111,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
</group>
<group string="User Interface">
<field name="graph_view_id"/>
<field name="pivot_view_id"/>
<field name="search_view_id"/>
<field name="action_id"/>
<field name="menu_id"/>

Loading…
Cancel
Save