Skip to content

Conversation

@legalsylvain
Copy link
Contributor

@legalsylvain legalsylvain commented Oct 25, 2022

  • move menu and action in according view file
  • use new sql_request_abstract menu entry for SQL views configuration
  • Use sql_request_abstract primary tree view
  • Use sql_request_abstract primary form view
  • move has_grouped_changed in sql_request_abstract module
  • improve demo data
  • add default count value to display in pivot, if no pivot_measures are defined ;
  • set widget handle to sequence field
  • reorder fields in tree view and add optional hide for some fields
  • simplify : make field_description field required
  • improve : add optional='hide' and 'show' on tree visibility
  • Cherri-pick : [IMP] bi_sql_editor : add field context #566

Depends on #669

Description

This module extends the functionality of reporting, to support creation
of extra custom reports.
It allows user to write a custom SQL request. (Generally, admin users)

Once written, a new model is generated, and user can map the selected field
with odoo fields.
Then user ends the process, creating new menu, action and graph view.

Technically, the module create SQL View (or materialized view, if option is
checked). Materialized view duplicates datas, but request are fastest. If
materialized view is enabled, this module will create a cron task to refresh
the data).

By default, users member of 'SQL Request / User' can see all the views.
You can specify extra groups that have the right to access to a specific view.

Warning

This module is intended for technician people in a company and for Odoo integrators.

It requires the user to know SQL syntax and Odoo models.

If you don't have such skills, do not try to use this module specially on a production
environment.

Use Cases

this module is interesting for the following use cases

  • You want to realize technical SQL requests, that Odoo framework doesn't allow
    (For exemple, UNION with many SELECT) A typical use case is if you want to have
    Sale Orders and PoS Orders datas in a same table

  • You want to customize an Odoo report, removing some useless fields and adding
    some custom ones. In that case, you can simply select the fields of the original
    report (sale.report model for exemple), and add your custom fields

  • You have a lot of data, and classical SQL Views have very bad performance.
    In that case, MATERIALIZED VIEW will be a good solution to reduce display duration

configure

  • Go to Dashboard / Configuration / SQL Views

  • tip your SQL request

01_sql_request

  • Select the group(s) that could have access to the view

02_security_access

Optionnaly, you can add a domain.

A tipical domain in a multi company context is to write
['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]
to make reporting depending on the current companies of the user.

  • Click on the button 'Validate SQL Expression'

  • Once the sql request checked, the module analyses the column of the view,
    and propose field mapping. For each field, you can decide to create an index
    and set if it will be displayed on the pivot graph as a column, a row or a
    measure.

03_field_mapping

  • Click on the button 'Create SQL elements'. (this step could
    take a while, if view is materialized)

  • If it's a MATERIALIZED view:

    • a cron task is created to refresh
      the view. You can so define the frequency of the refresh.
    • the size of view (and the indexes is displayed)

04_materialized_view_setting

  • Finally, click on 'Create UI', to create new menu, action, graph view and
    search view.

@legalsylvain
Copy link
Contributor Author

/ocabot migration bi_sql_editor

@OCA-git-bot
Copy link
Contributor

Sorry @legalsylvain you are not allowed to mark the addon tobe migrated.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

@rvalyi
Copy link
Member

rvalyi commented Oct 26, 2022

/ocabot migration bi_sql_editor

@bealdav
Copy link
Member

bealdav commented Nov 23, 2022

Probably needs a rebase because of sql_request_abstract merged cc @legalsylvain

@legalsylvain
Copy link
Contributor Author

/ocabot rebase

@OCA-git-bot
Copy link
Contributor

Sorry @legalsylvain you are not allowed to rebase.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

@bealdav
Copy link
Member

bealdav commented Nov 23, 2022

Oops @legalsylvain you probably needs to remove test-requirement.txt

@legalsylvain legalsylvain force-pushed the 16.0-mig-bi_sql_editor branch from 01a614e to 61b434f Compare November 23, 2022 15:24
@legalsylvain
Copy link
Contributor Author

/ocabot rebase

@OCA-git-bot
Copy link
Contributor

Sorry @legalsylvain you are not allowed to rebase.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

@legalsylvain
Copy link
Contributor Author

Oops @legalsylvain you probably needs to remove test-requirement.txt

Done. CI is right. Thanks for updating your review.

Copy link
Member

@bealdav bealdav left a comment

Choose a reason for hiding this comment

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

Only review in 3 last commits
Tested on runboat

Thanks a lot

Copy link
Contributor

@florian-dacosta florian-dacosta left a comment

Choose a reason for hiding this comment

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

Code review only
Just one remark @legalsylvain

"many2one_model_id": many2one_model_id,
}
)
return super().create(vals)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems quite wrong to me, should be vals_list instead of vals right ?

Copy link
Member

Choose a reason for hiding this comment

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

Good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for your review !
fixed.

@legalsylvain legalsylvain force-pushed the 16.0-mig-bi_sql_editor branch from 61b434f to 6b2bf44 Compare November 26, 2022 20:22
@legalsylvain
Copy link
Contributor Author

legalsylvain commented Dec 25, 2022

I have to cherry pick #566 (comment)

Edit : 01/03/2022 : done.

Ready to be merged.

OCA-git-bot and others added 21 commits February 17, 2023 10:19
[UPD] README.rst
Currently translated at 38.3% (43 of 112 strings)

Translation: reporting-engine-13.0/reporting-engine-13.0-bi_sql_editor
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-13-0/reporting-engine-13-0-bi_sql_editor/es/
this commit allows specifying the group operator for each field. This functionality was originally included in a seperate module "bi_sql_editor_aggregate" in version 12.
On class creation by the ORM of 'manual' model, odoo now check if the table is a real table or a view to automatically set the '_auto' property on the class definition. We can therefore remove the monkey patch on 'ir.model'.

see odoo/odoo@17c4f47
Currently translated at 41.0% (46 of 112 strings)

Translation: reporting-engine-15.0/reporting-engine-15.0-bi_sql_editor
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-0-bi_sql_editor/ca/
Currently translated at 97.3% (109 of 112 strings)

Translation: reporting-engine-15.0/reporting-engine-15.0-bi_sql_editor
Translate-URL: https://translation.odoo-community.org/projects/reporting-engine-15-0/reporting-engine-15-0-bi_sql_editor/ca/
- move menu and action in according view file
- use new sql_request_abstract menu entry for SQL views configuration
- Use sql_request_abstract primary tree view
- Use sql_request_abstract primary form view
- move has_grouped_changed in sql_request_abstract module
- improve demo data
- add default count value to display in pivot, if no pivot_measures are defined ;
- set widget handle to sequence field
- reorder fields in tree view and add optional hide for some fields
- simplify : make field_description field required
- improve : add optional='hide' and 'show' on tree visibility
- replace obsolete base.menu_board_root by spreadsheet_dashboard entries
- update translation
The `table_columns()` slows down modules loading significantly up to 2-3x.
In most cases `model._name.startswith(self._model_prefix)` returns `False`, so better to check it first.
@OCA-git-bot
Copy link
Contributor

Congratulations, PR rebased to 16.0.

@OCA-git-bot OCA-git-bot force-pushed the 16.0-mig-bi_sql_editor branch from 3372a0b to c55dc6f Compare February 17, 2023 10:19
@gurneyalex
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-670-by-gurneyalex-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 4010f4b into OCA:16.0 Feb 17, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at ff0d4f1. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.