[9.0] MIG bi_sql_editor - #148
Conversation
…ield; [ADD] security
|
I ❤️ this module. Would you include the changes proposed here #149 ? |
|
@aheficent perhaps you can propose a PR that includes it |
|
please wait, i'm doing some improvement on #149. |
|
improvment available here : #150 |
|
Hi @aheficent. Thanks a lot for porting this module. LGTM for me (code / test). please ping me once you integrated #150 commit. |
|
Sure @legalsylvain Thank you for the improvement |
|
@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
|
@jbeficent thanks for the PR |
|
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
left a comment
There was a problem hiding this comment.
LGTM to me. one comment on demo data to update.
Otherwise, 👍
Thanks !
PS : could you review, the V8.0 PR ?
#150
| SELECT | ||
| name as x_name, | ||
| case | ||
| when author ilike '%OpenERP SA%' THEN 'Odoo SA' |
There was a problem hiding this comment.
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
|
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 |
|
Any other review to validate the PR ? thanks ! |
|
Can we add an option for the person thay creates the query to decide the order of the.views? (Treen graph, pivot)? |
|
@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: Honestly, don't know the reason |
| take a while, if view is materialized) | ||
|
|
||
| * If it's a MATERIALIZED view: | ||
| * a cron task is created to refresh |
|
|
||
| To use this module, you need to: | ||
|
|
||
| * Go to 'Reporting' / 'Custom Reports' |
There was a problem hiding this comment.
Best would be enumerated list (nice to have)
| 'views/menu.xml', | ||
| ], | ||
| 'demo': [ | ||
| 'demo/res_groups.xml', |
| License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
| --> | ||
|
|
||
| <openerp><data> |
|
|
||
| technical_name = fields.Char( | ||
| string='Technical Name', required=True, | ||
| help="Suffix of the SQL view. (SQL full name will be computed and" |
| 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" |
There was a problem hiding this comment.
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" |
| many2one_model_id = fields.Many2one( | ||
| comodel_name='ir.model', string='Model', | ||
| help="For 'Many2one' Odoo field.\n" | ||
| " Co Model of the field.") |
We could
No time for this feature, for my side, but ok to review it. (It could be done in the second PR.) |
|
@legalsylvain I'll propose a PR for that |
|
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 |
[IMP]bi_sql_editor. Select View Order.
legalsylvain
left a comment
There was a problem hiding this comment.
Hi thanks a lot for adding a hook.
Some comments inline however.
thanks.
| sql_view.action_id.unlink() | ||
| sql_view.menu_id.unlink() | ||
| sql_view.rule_id.unlink() | ||
| if sql_view.tree_view_id: |
There was a problem hiding this comment.
why did you added a test ? if rule_id is False, sql_view.r_le_id.unlink() make nothing.
| rec.button_set_draft() | ||
| rec.unlink() | ||
|
|
||
| # delete dirty data that could cause problems |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
|
||
| # Drop table if uninstalling went wrong | ||
| cr.execute(""" | ||
| delete from ir_model_fields where model like 'bi.sql.view%'; |
There was a problem hiding this comment.
better to do sql_view.model_id.unlink(), don't you think ?
There was a problem hiding this comment.
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: |
|
BTW, travis compilation was not failing because of the test here but for a test in another module: test_report_qweb_pdf_watermark |
|
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. |
|
@mreficent All right. I'll try to fix that |
|
@aheficent sorry, yes, the problem is with |
|
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 |
|
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:
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. |
|
Created Pull Request here to fix flake8 error https://github.com/adhoc-dev/reporting-engine-1/pull/8 However this is still pending: Does anybody knows how to configure travis file to avoid this check? 🙏 |
|
@aheficent :
Sample : https://github.com/OCA/server-tools/blob/10.0/database_cleanup/models/purge_columns.py#L51 regards; |
|
Thank you @legalsylvain! I added this to my last Pull Request. (https://github.com/adhoc-dev/reporting-engine-1/pull/8) |
|
@jbeficent , @aheficent could you set a little +1 on the PR against V8 you cherry picked ? thanks ! |
|
Runbot is compiled. It's showing red because of this: 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. |
|
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. |
[UPT]add test
|
@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 |
|
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', |
JordiBForgeFlow
left a comment
There was a problem hiding this comment.
Technical and functional review 👍
|
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. |
|
Well, I propose to merge this PR, because it's OK. (and it has 6 👍, that's a record ! ) |
No description provided.