-
-
Notifications
You must be signed in to change notification settings - Fork 714
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
product_main_supplierinfo: fix default sellers for variant #1077
product_main_supplierinfo: fix default sellers for variant #1077
Conversation
Hi @sebalix, |
5f49df3
to
1188715
Compare
@@ -49,5 +49,7 @@ def _get_sellers(self): | |||
) | |||
) | |||
if not sellers: | |||
sellers = all_sellers | |||
sellers = all_sellers.filtered(lambda s: (s.product_id == self)) |
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 would suggest then:
sellers = all_sellers.filtered(lambda s: (s.product_id == self)) | |
sellers = all_sellers.filtered(lambda s: (s.product_id == self)) | |
if not sellers: | |
# Fallback on template sellers if there is none for the current variant | |
sellers = all_sellers.filtered(lambda s: not s.product_id) |
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.
In the same logic, added.
sellers = all_sellers | ||
sellers = all_sellers.filtered(lambda s: (s.product_id == self)) | ||
if not sellers: | ||
sellers = all_sellers | ||
return sellers |
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.
We could also add this to be in-line with what Odoo does:
return sellers | |
return sellers.sorted("price") |
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.
Done, tested on a purchase order and if multiple supplier info record are matching Odoo will select the cheaper alternative even if it has a higher sequence.
1188715
to
519ff7b
Compare
@TDu your tests are now failing :) |
519ff7b
to
4ba4191
Compare
@sebalix Tests are good now... |
@TDu can you squash and rewrite the commit msg (eg: = PR title)? |
4ba4191
to
d3a92f9
Compare
Squashed and renamed. But Travis failed and it does not make sense to me https://app.travis-ci.com/github/OCA/product-attribute/jobs/571634140#L2242 |
If no specific record are found by the first filter. The Odoo default method will return all active supplier info. Which will include also supplier info record related to other specific variant. With this change if some supplier info related to the product variant exist, they will be returned instead. Also add a sort on the price to have the same behaviour than on a purchase order line for the price selected.
d777d24
to
ea0f7f6
Compare
That fix worked so squashed again... |
/ocabot merge patch |
This PR looks fantastic, let's merge it! |
This PR has the |
Congratulations, your PR was merged at f2ae482. Thanks a lot for contributing to OCA. ❤️ |
If no specific record are found by the first filter. The Odoo default
method will return all active supplier info.
Which will include also supplier info record related to other specific
variant.
With this change if some supplier info related to the product
variant exist, they will be returned instead.