Task Description
In some case, when trying to display the context menu on a
pivot cell (doesn't seem to impact PIVOT.HEADER), we get a
traceback caused by the arguments of the formula take into
account in the ´getFiltersMatchingPivot`, called by the
"isVisible" property evaluation of the "set as filter" action.
These errors only rise when using a pivot with "__count" as
measure and a positional argument.
Moreover, when trying to open the context menu with a filter
defined without any field, we get another traceback.
Reproducibility
The first issue can be reproduced with the following steps:
1. Go to the CRM app
2. Create a pivot view
3. Group the row by Country
4. "Ungroup" the columns (keep only the total)
5. Set "__count" as measure
6. Insert the pivot on a new spreadsheet
7. Edit the pivot formulas to use positional argument for country_id
8. Insert a new filter on the country field
9. Right click on a pivot cell
The second issue can be reproduced with the following steps:
1. Open a spreadsheet with a pivot
2. Add a filter related to the pivot but without any field matching
3. Right-click on a pivot cell
Fix Description
The first issue is coming from the fact we try to get the value related
to a field in the pivot formula using the 2nd and 3rd argument instead
of using the last two arguments of the formula. This is fixed by passing
to getPivotHeaderValue only the last two arguments of the pivot formula.
For the second issue, we simply check that the pivot field is defined
before looking at its name.
Related Task
task-2999181
closesodoo/odoo#102204
X-original-commit: 15e0c8aba57d4e0a8c58f288a4e96f0bc884736c
Related: odoo/enterprise#32303
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>