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
[FIX] analytic: plan's applicability don't work without companies #162152
Conversation
1e916d0
to
86cb417
Compare
There was a problem hiding this 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'}) |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okaaaay, got it ! Thanks :)
86cb417
to
a068b6d
Compare
a068b6d
to
44692ba
Compare
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") |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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
c77a581
to
aaf18a4
Compare
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
aaf18a4
to
6221341
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robodoo r+
@@ -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'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okaaaay, got it ! Thanks :)
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>
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>
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>
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