Skip to content

[9.0] MIG bi_sql_editor - #148

Merged
JordiBForgeFlow merged 19 commits into
OCA:9.0from
adhoc-dev:9.0-mig-bi_sql_editor
Aug 11, 2017
Merged

JordiBForgeFlow merged 19 commits into
OCA:9.0from
adhoc-dev:9.0-mig-bi_sql_editor

Conversation

@nicomacr

Copy link
Copy Markdown
Contributor

No description provided.

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

I ❤️ this module. Would you include the changes proposed here #149 ?

@JordiBForgeFlow

Copy link
Copy Markdown
Member

@aheficent perhaps you can propose a PR that includes it

@legalsylvain

Copy link
Copy Markdown
Contributor

please wait, i'm doing some improvement on #149.

@legalsylvain

Copy link
Copy Markdown
Contributor

improvment available here : #150

@legalsylvain

Copy link
Copy Markdown
Contributor

Hi @aheficent. Thanks a lot for porting this module. LGTM for me (code / test). please ping me once you integrated #150 commit.
regards.

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

Sure @legalsylvain Thank you for the improvement

@JordiBForgeFlow

Copy link
Copy Markdown
Member

@nicomacr @legalsylvain @aheficent I have improved 9.0 with the cherry pick of #150 here: adhoc-dev#1

[IMP] fr translation
[IMP] add last refresh date time on the action name of each sql materialized view
@nicomacr

Copy link
Copy Markdown
Contributor Author

@jbeficent thanks for the PR

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

Hi @nicomacr I'm proposing some tests here: https://github.com/adhoc-dev/reporting-engine-1/pull/2 . Also it fixes the unlink method, which is not calling super.

@legalsylvain legalsylvain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to me. one comment on demo data to update.

Otherwise, 👍
Thanks !

PS : could you review, the V8.0 PR ?
#150

Comment thread bi_sql_editor/demo/bi_sql_view.xml Outdated
SELECT
name as x_name,
case
when author ilike '%OpenERP SA%' THEN 'Odoo SA'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because, odoo renamed authorship in V9.

case
    when author ilike '%OpenERP SA%' THEN 'Odoo SA'
    when author ilike '%Odoo SA%' THEN 'Odoo SA'
    when author ilike '%Odoo Community Association (OCA)%' THEN 'OCA'
   else 'Undefined Author' END as x_author_type

@AaronHForgeFlow

AaronHForgeFlow commented Jul 18, 2017

Copy link
Copy Markdown
Contributor

I closed the previous PR for the test. I created a new one here: https://github.com/adhoc-dev/reporting-engine-1/pull/3 but it's failing because it's creating a lot of connections to the database. I'll update the PR when this issue is solved

@legalsylvain

Copy link
Copy Markdown
Contributor

Any other review to validate the PR ? thanks !

@JordiBForgeFlow

Copy link
Copy Markdown
Member

Can we add an option for the person thay creates the query to decide the order of the.views? (Treen graph, pivot)?

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

@legalsylvain This works ok to me. However there's must be something wrong with the test I did because when I run it on local it's trying to connect to the database multiple times. Getting this:
PoolError: The Connection Pool Is Full

Honestly, don't know the reason

@elicoidal elicoidal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one

Comment thread bi_sql_editor/README.rst
take a while, if view is materialized)

* If it's a MATERIALIZED view:
* a cron task is created to refresh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a blank line

Comment thread bi_sql_editor/README.rst Outdated

To use this module, you need to:

* Go to 'Reporting' / 'Custom Reports'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best would be enumerated list (nice to have)

Comment thread bi_sql_editor/__openerp__.py Outdated
'views/menu.xml',
],
'demo': [
'demo/res_groups.xml',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demo/res_groups_demo.xml (several)

Comment thread bi_sql_editor/demo/res_groups.xml Outdated
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

<openerp><data>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odoo
+Improve the format

Comment thread bi_sql_editor/models/bi_sql_view.py Outdated

technical_name = fields.Char(
string='Technical Name', required=True,
help="Suffix of the SQL view. (SQL full name will be computed and"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove (

Comment thread bi_sql_editor/models/bi_sql_view.py Outdated
technical_name = fields.Char(
string='Technical Name', required=True,
help="Suffix of the SQL view. (SQL full name will be computed and"
" prefixed by 'x_bi_sql_view_'. Should have correct"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax should follow: https://www.postgresql.org/"
"docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS


ttype = fields.Selection(
string='Field Type', selection=_TTYPE_SELECTION, help="Type of the"
" Odoo field that will be created. Let empty if you don't want to"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/let/keep

many2one_model_id = fields.Many2one(
comodel_name='ir.model', string='Model',
help="For 'Many2one' Odoo field.\n"
" Co Model of the field.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comodel

@legalsylvain

Copy link
Copy Markdown
Contributor

Can we add an option for the person that creates the query to decide the order of the.views? (Treen graph, pivot)?

We could

  • add an extra char field in the view, with a default value to 'graph,pivot,tree', (readonly if sql is not in the draft / analyzed state)
  • add a constraint that check that value.split(',') contains only ['graph', 'pivot', 'tree']
  • use this value to generate the action. (and use it in the button_open_ui)

No time for this feature, for my side, but ok to review it. (It could be done in the second PR.)

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

@legalsylvain I'll propose a PR for that

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

Hi @nicomacr @legalsylvain I added an option for the person that creates the query to decide the first view to show: https://github.com/adhoc-dev/reporting-engine-1/pull/4

@legalsylvain legalsylvain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thanks a lot for adding a hook.
Some comments inline however.

thanks.

Comment thread bi_sql_editor/models/bi_sql_view.py Outdated
sql_view.action_id.unlink()
sql_view.menu_id.unlink()
sql_view.rule_id.unlink()
if sql_view.tree_view_id:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you added a test ? if rule_id is False, sql_view.r_le_id.unlink() make nothing.

Comment thread bi_sql_editor/hooks.py Outdated
rec.button_set_draft()
rec.unlink()

# delete dirty data that could cause problems

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand all the lines below. 15+
for me button_set_draft() and unlink() are enought, to drop all the (materialized or not) views.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check that again without tests. But with them that was not enough, because it creates a lot of dirty data in the database. Thank you @legalsylvain

Comment thread bi_sql_editor/hooks.py Outdated

# Drop table if uninstalling went wrong
cr.execute("""
delete from ir_model_fields where model like 'bi.sql.view%';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to do sql_view.model_id.unlink(), don't you think ?

@AaronHForgeFlow AaronHForgeFlow Jul 28, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the same. This is supposed to be done by this line rec.button_set_draft() But for some reason it does not work properly. At the end it shows this error:

Unable to delete 121@ir.model
and then:
UserError: (u"The field 'bi.sql.view.field.bi_sql_view_id' cannot be removed because the field 'bi.sql.view.bi_sql_view_field_ids' depends on it.", None)

That's why I put all those queries.

def _drop_model_and_fields(self):
for sql_view in self:
sql_view.model_id.unlink()
if sql_view.model_id:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

BTW, travis compilation was not failing because of the test here but for a test in another module: test_report_qweb_pdf_watermark

@MiquelRForgeFlow

MiquelRForgeFlow commented Jul 28, 2017

Copy link
Copy Markdown
Contributor

No, Travis now is not failing by the pdf_watermark. It seems it is failing because it cannot install some external libraries. They should be added in Travis or something like this may be.

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

@mreficent All right. I'll try to fix that

@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

@aheficent sorry, yes, the problem is with report_qweb_pdf_watermark

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

BTW among other things, Lint check fails because of the queries in the uninstall hook. But those queries are necessary IMO so I'd keep that

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

Hi @legalsylvain I created another Pull Request here to attend your comments. Despite my previous comment I realized that those queries in the uninstall hook are not needed. However this error is still shown when uninstalling:

Unable to delete 121@ir.model
and then:
UserError: (u"The field 'bi.sql.view.field.bi_sql_view_id' cannot be removed because the field 'bi.sql.view.bi_sql_view_field_ids' depends on it.", None)

Nevertheless, no bi.sql.view and no bi.sql.view.field remains in the database when uninstalling. That's why I removed the queries from the uninstall hook.

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

Created Pull Request here to fix flake8 error https://github.com/adhoc-dev/reporting-engine-1/pull/8

However this is still pending:
https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md#no-sql-injection

Does anybody knows how to configure travis file to avoid this check? 🙏

@legalsylvain

Copy link
Copy Markdown
Contributor

@aheficent :

self.env.cr.commit() # pylint: disable=invalid-commit

Sample : https://github.com/OCA/server-tools/blob/10.0/database_cleanup/models/purge_columns.py#L51

regards;

@AaronHForgeFlow

AaronHForgeFlow commented Jul 31, 2017

Copy link
Copy Markdown
Contributor

Thank you @legalsylvain! I added this to my last Pull Request. (https://github.com/adhoc-dev/reporting-engine-1/pull/8)

@legalsylvain

Copy link
Copy Markdown
Contributor

@jbeficent , @aheficent could you set a little +1 on the PR against V8 you cherry picked ?
#150.

thanks !

@AaronHForgeFlow

AaronHForgeFlow commented Aug 1, 2017

Copy link
Copy Markdown
Contributor

Runbot is compiled. It's showing red because of this:
ParseError: "no such savepoint " while parsing /home/odoo/build/OCA/reporting-engine/bi_sql_editor/demo/bi_sql_view_demo.xml:52, near <function model="bi.sql.view" name="button_validate_sql_expression" eval="([ref('module_sql_view')])"/>

Should we create a savepoint before calling the method button_validate_sql_expression?

Edit: Run in local in debug mode. Same error as here travis is getting. In the second try it fails for different reason, the relations created for the demo data in the previous try were still there. Same problem as the one I was having with the tests.

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

Hi @nicomacr I created a new PR here: https://github.com/adhoc-dev/reporting-engine-1/pull/9

This fixes the error related with the save point that was introduced in the last commit. Besides I added some tests back. However, the tests don't cover the part of creating the models because that would leave unwanted data in the database.
@legalsylvain @jbeficent

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

@nicomacr Sorry for the Lint errors. 🤕 Created new PR for that:https://github.com/adhoc-dev/reporting-engine-1/pull/10 Probably a commit squashing will be needed later

@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

Created PR to prevent runbot warning https://github.com/adhoc-dev/reporting-engine-1/pull/11

Travis will be fixed when this is merged: #154

'relation': self.ttype == 'many2one' and
self.many2one_model_id.model or False,
'tree_visibility': self.field_description and
'available' or 'unavailable',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks !

@JordiBForgeFlow JordiBForgeFlow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical and functional review 👍

@JordiBForgeFlow

Copy link
Copy Markdown
Member

Travis is KO due to problem found in #154. But tested locally, and all test are passing correctly.

The only problem we found is that it is not possible to include in the tests the parts where the models are created, because every time that you pass the test the tables created by the test are not deleted from the DB -- very strange --, so the next time you run the test, it fails because the table already exists.

@JordiBForgeFlow
JordiBForgeFlow merged commit f94fe24 into OCA:9.0 Aug 11, 2017
@legalsylvain

Copy link
Copy Markdown
Contributor

Well, I propose to merge this PR, because it's OK. (and it has 6 👍, that's a record ! )
let's go improving test in another PR, or for another version. (8.0 version didn't include test at all, so, it's better).

@jjscarafia
jjscarafia deleted the 9.0-mig-bi_sql_editor branch August 11, 2017 11:42
SimoneVagile pushed a commit to SimoneVagile/reporting-engine that referenced this pull request Jan 25, 2021
Signed-off-by pedrobaeza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.