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] analytic: plan's applicability don't work without companies #162152

Conversation

gawa-odoo
Copy link
Contributor

If you create an applicability and remove the company field, they are never used.
An applicability like this should be valid for all companies.
We put a 0.5 value for the company field so an applicability so it has a lesser priority than other fields.
Same idea as the distribution models.

opw-3847415


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

@robodoo
Copy link
Contributor

robodoo commented Apr 17, 2024

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Apr 17, 2024
@gawa-odoo gawa-odoo force-pushed the 17.0-analytic-applicabilities_companies-gawa branch from 1e916d0 to 86cb417 Compare April 17, 2024 10:08
@gawa-odoo gawa-odoo requested review from a team and RicGR98 and removed request for a team April 17, 2024 15:01
Copy link
Contributor

@RicGR98 RicGR98 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR :)

@@ -76,8 +76,7 @@ def test_validate_company_plans(self):
'name': 'Mandatory Plan',
'default_applicability': 'optional',
}])
mandatory_plan.with_company(company_2).write({'default_applicability': 'mandatory'})
Copy link
Contributor

Choose a reason for hiding this comment

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

The mandatory_plan created above is no more mandatory without this line. Is this normal ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well it wasn't quite mandatory, it was only mandatory for self.env.company
And either this definition, or the applicability defined below was completely useless as they both did the same thing (on the only thing that was tested).
To be able to test other situations, I removed the default_applicability.
Doing so, I now changed the name of the variable, to reflect the difference

Copy link
Contributor

Choose a reason for hiding this comment

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

Okaaaay, got it ! Thanks :)

addons/account/tests/test_account_analytic.py Show resolved Hide resolved
@gawa-odoo gawa-odoo force-pushed the 17.0-analytic-applicabilities_companies-gawa branch from 86cb417 to a068b6d Compare April 19, 2024 13:32
@gawa-odoo gawa-odoo requested a review from RicGR98 April 19, 2024 13:54
@RicGR98 RicGR98 requested a review from oco-odoo April 19, 2024 13:59
@gawa-odoo gawa-odoo force-pushed the 17.0-analytic-applicabilities_companies-gawa branch from a068b6d to 44692ba Compare April 23, 2024 09:56
score = applicability_without_company._get_score(business_domain='invoice', product=self.product_a.id)
self.assertEqual(score, 2, "company_id shouldn't be taken into account")
score = applicability_with_company._get_score(business_domain='invoice', product=self.product_a.id)
self.assertEqual(score, 1, "company_id shouldn't be taken into account either")
Copy link
Contributor

Choose a reason for hiding this comment

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

I find the message a bit misleading here (especially the "either"). Not sure those two (this one and the one above) make the test any more explicit. Wouldn't it be just better, to leave those two assertEqual without error message ? The "product takes precedence over company" above already states the expected behavior, if I get the test well 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not exactly, we're not really testing the same thing.
But still, I reworded the message to make clearer what I wanted to test in these 2 asserts as indeed, it wasn't explicit

@gawa-odoo gawa-odoo force-pushed the 17.0-analytic-applicabilities_companies-gawa branch 2 times, most recently from c77a581 to aaf18a4 Compare April 25, 2024 15:42
@gawa-odoo gawa-odoo requested a review from oco-odoo April 25, 2024 15:43
If you create an applicability and remove the company field,
they are never used.
An applicability like this should be valid for all companies.
We put a 0.5 value for the company field so an applicability
so it has a lesser priority than other fields.
Same idea as the distribution models.

opw-3847415
@gawa-odoo gawa-odoo force-pushed the 17.0-analytic-applicabilities_companies-gawa branch from aaf18a4 to 6221341 Compare April 26, 2024 06:58
Copy link
Contributor

@oco-odoo oco-odoo left a comment

Choose a reason for hiding this comment

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

@@ -76,8 +76,7 @@ def test_validate_company_plans(self):
'name': 'Mandatory Plan',
'default_applicability': 'optional',
}])
mandatory_plan.with_company(company_2).write({'default_applicability': 'mandatory'})
Copy link
Contributor

Choose a reason for hiding this comment

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

Okaaaay, got it ! Thanks :)

robodoo pushed a commit that referenced this pull request Apr 26, 2024
If you create an applicability and remove the company field,
they are never used.
An applicability like this should be valid for all companies.
We put a 0.5 value for the company field so an applicability
so it has a lesser priority than other fields.
Same idea as the distribution models.

opw-3847415

closes #162152

Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
robodoo pushed a commit that referenced this pull request Apr 26, 2024
If you create an applicability and remove the company field,
they are never used.
An applicability like this should be valid for all companies.
We put a 0.5 value for the company field so an applicability
so it has a lesser priority than other fields.
Same idea as the distribution models.

opw-3847415

closes #162152

Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
@robodoo robodoo closed this in ffcf2ee Apr 26, 2024
willylohws pushed a commit to willylohws/odoo that referenced this pull request May 1, 2024
If you create an applicability and remove the company field,
they are never used.
An applicability like this should be valid for all companies.
We put a 0.5 value for the company field so an applicability
so it has a lesser priority than other fields.
Same idea as the distribution models.

opw-3847415

closes odoo#162152

Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants