Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] spreadsheet: falsy pivot values #165976

Closed

Conversation

dhrp-odoo
Copy link
Contributor

@dhrp-odoo dhrp-odoo commented May 17, 2024

Description:

Previously, when entering a pivot and applying a filter domain, the pivot formula (without domain field and domain value in function parameter) would return 'FALSE' if it did not match any records. The code now checks the value and returns an empty string if it's 'FALSE'.

Task - 3888401


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented May 17, 2024

Pull request status dashboard.

@C3POdoo C3POdoo requested a review from a team May 17, 2024 12:42
@C3POdoo C3POdoo added the RD research & development, internal work label May 17, 2024
@rrahir
Copy link
Contributor

rrahir commented May 17, 2024

Hi :)
I think there might be a misunderstanding between the task description, which seems to specifically address the TOTAL fomulas and the PR description which seems to address every pivot formula. Could you check this?
Also, a test is required ;-)

@dhrp-odoo dhrp-odoo force-pushed the 17.0-fix-falsy-aggregated-values-dhrp branch from 77194a7 to f2f019b Compare May 20, 2024 12:26
@dhrp-odoo
Copy link
Contributor Author

@rrahir, I have revised both the commit and PR message for clarity. Regarding the test, I've attempted it previously and again now, but I am receiving 0 instead of an empty string when pivot does not match any data. Functionally, it is working as expected. I am pushing a broken test. Could you provide insight if you are aware of any potential reasons for this issue? Thanks :)


if (
values &&
Object.prototype.hasOwnProperty.call(values[0], measure) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It checks if values[0] has a property called measure.

Previously, I used values[0].hasOwnProperty, but encountered an ESLint error while playing around with tests: Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins.

@rrahir rrahir force-pushed the 17.0-fix-falsy-aggregated-values-dhrp branch from f2f019b to a702bb9 Compare May 22, 2024 13:05
Copy link
Contributor

@rrahir rrahir left a comment

Choose a reason for hiding this comment

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

I added a commit (so don't push force pbut rather pull the branch locally) which fixes the mocking of read_group, it did not follow the server behaviour.


if (
values &&
Object.prototype.hasOwnProperty.call(values[0], measure) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to do this? if the measure is not present, values[0][measure] will be undefined and you get out of the if statement as well. So this condition is a duplicate of the following line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct; this line is unnecessary. It was initially added while experimenting with tests and addressing an ESLint error. Thank you for the commit related to mockRPC 😊. I took the liberty of updating the commit message as suggested by AAB.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks a lot! the fix seems good :)

@C3POdoo C3POdoo requested review from a team, aab-odoo and BastienFafchamps and removed request for a team May 22, 2024 13:08
Copy link
Contributor

@aab-odoo aab-odoo left a comment

Choose a reason for hiding this comment

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

Commit message: [FIX] web: ...

@aab-odoo
Copy link
Contributor

aab-odoo commented May 22, 2024

Don't forget to also fix the hoot mock server in the forward ports (>= 17.2), as it most likely has the same issue

@dhrp-odoo dhrp-odoo force-pushed the 17.0-fix-falsy-aggregated-values-dhrp branch from a702bb9 to 33a7dcd Compare May 23, 2024 05:24
rrahir and others added 2 commits May 23, 2024 14:24
`mockReadGroup` did not follow the server implementation in the case of
missing groupby (did not return __domain key) and was returning `0`
instead of `False` for the aggregate value when the domain did not match
any records.
Previously, when entering a pivot and applying a filter domain,
the pivot formula (without any domain field and domain value) would
return 'FALSE' if it did not match any records. The code now checks
the value and returns an empty string if it's false.

Task-3888401
@dhrp-odoo dhrp-odoo force-pushed the 17.0-fix-falsy-aggregated-values-dhrp branch from 33a7dcd to aeca219 Compare May 23, 2024 08:55
@rrahir
Copy link
Contributor

rrahir commented May 31, 2024

@robodoo rebase-ff

@robodoo
Copy link
Contributor

robodoo commented May 31, 2024

Merge method set to rebase and fast-forward.

@rrahir
Copy link
Contributor

rrahir commented May 31, 2024

@robodoo r+

robodoo pushed a commit that referenced this pull request May 31, 2024
`mockReadGroup` did not follow the server implementation in the case of
missing groupby (did not return __domain key) and was returning `0`
instead of `False` for the aggregate value when the domain did not match
any records.

Part-of: #165976
@robodoo robodoo closed this in 8d62f00 May 31, 2024
@fw-bot
Copy link
Contributor

fw-bot commented Jun 4, 2024

@dhrp-odoo @rrahir this pull request has forward-port PRs awaiting action (not merged or closed):

@fw-bot
Copy link
Contributor

fw-bot commented Jun 5, 2024

@dhrp-odoo @rrahir this pull request has forward-port PRs awaiting action (not merged or closed):

lohwswilson pushed a commit to lohwswilson/odoo that referenced this pull request Jun 5, 2024
`mockReadGroup` did not follow the server implementation in the case of
missing groupby (did not return __domain key) and was returning `0`
instead of `False` for the aggregate value when the domain did not match
any records.

Part-of: odoo#165976
lohwswilson pushed a commit to lohwswilson/odoo that referenced this pull request Jun 5, 2024
Previously, when entering a pivot and applying a filter domain,
the pivot formula (without any domain field and domain value) would
return 'FALSE' if it did not match any records. The code now checks
the value and returns an empty string if it's false.

Task-3888401

closes odoo#165976

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants