-
-
Notifications
You must be signed in to change notification settings - Fork 715
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
[17.0][MIG] product_main_supplierinfo #1660
[17.0][MIG] product_main_supplierinfo #1660
Conversation
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.
962ec11
to
7c662c7
Compare
Can you review, please? |
Tested on runboat 👍 |
Can you review please? |
if not sellers: | ||
sellers = all_sellers.filtered(lambda s: (s.product_id == self)) | ||
if not sellers: | ||
sellers = 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.
this line is weird, could you explain the use of the duplicate assignation on the same variable?
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.
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.
This looks like a typo, should be IMO
sellers = sellers = all_sellers.filtered(lambda s: not s.product_id) | |
sellers = all_sellers.filtered(lambda s: not s.product_id) |
Also the directory |
7c662c7
to
08a9af4
Compare
Done! Review please @TDu |
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.
LGTM
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.
LGTM, thanks
/ocabot migration product_main_supplierinfo |
/ocabot merge nobump |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 6700f6f. Thanks a lot for contributing to OCA. ❤️ |
sellers = product._get_sellers() | ||
product.main_seller_id = fields.first(sellers) | ||
|
||
def _get_sellers(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.
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.
Good question, had to re-check the original v14 PR to see if I mentioned something there, but nothing!
The only difference that remembers me a thing is that _select_seller()
is sorting the sellers based on price
before returning one (which is OK when encoding a PO). Here the price is not a criteria to become the "main vendor" of a product, but sequence and dates matter.
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.
Just saw that starting from Odoo v17, _select_seller
method accepts a new ordered_by
parameter, which could be used to force the use of sequence
, if that works we could drop this method 🤔
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.
It's not that neither, we are sorting on the price at the end of this method too... I don't remember then why I duplicated this code, for sure there is a reason.
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.
Find out, so we could not use _select_seller
in v14 because of this filter:
But starting from v15, which introduced the submethod _get_filtered_sellers
you were talking about, it should definitely work.
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.
Trying this here: #1812
One test is failing, to check.
Standard migration, reused #1353 (Unfinished migration to v16.0)