80d643c141de69914a77827d48cecddfc43787d2
When generating a spreadsheet from a pivot view, the values of m2o
fields are added up instead of being counted.
To reproduce the error:
(Need point_of_sale,documents_spreadsheet)
1. Open a POS session
2. Process 3 orders
3. Close the session
4. Point of Sale > Reporting > Orders - Pivot View
(Note: the number of orders is 3, which is correct)
5. Insert in Spreadsheet
Error: On spreadsheet, the number of orders is incorrect (the value
corresponds to the sum of the order identifier of each POS order line)
When generating the spreadsheet, here is how the operator for each field
is computed:
https://github.com/odoo/enterprise/blob/06bf2b0e2def3445cdd21d5b6fccc58e3015e0b5/documents_spreadsheet/static/src/js/o-spreadsheet/pivot_utils.js#L217-L225
If there is not any `group_operator`, the `operator` will be defined to
`sum`.
In the above case, the attribute `group_operator` is indeed not defined
for the field `order_id`:
https://github.com/odoo/odoo/blob/1ddbcb4860ee220e9f826e8b6f6b85b6c22fb2b7/addons/point_of_sale/report/pos_order_report.py#L14
However, when generating the pivot view, if the field is m2o, its
`group_operator` value is not considered and the operator is directly
defined to `count_distinct`:
https://github.com/odoo/odoo/blob/7cf8f6f40e5769d2f22620ac425208c4ad9ae80b/addons/web/static/src/js/views/pivot/pivot_model.js#L979-L987
Since the spreadsheet is based on the pivot view, this fix suggests
saving this decision so the spreadsheet will behave in the same way.
OPW-2551030
closes odoo/odoo#72020
X-original-commit: a7ada576df9bbd6c1fd1cbf082ba0a79ec7802f9
Related: odoo/enterprise#18945
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
Odoo
Odoo is a suite of web based open source business apps.
The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...
Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
Getting started with Odoo
For a standard installation please follow the Setup instructions from the documentation.
To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials
Languages
Python
49.6%
JavaScript
47.8%
SCSS
2%
CSS
0.3%
HTML
0.2%