[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.
this line is weird, could you explain the use of the duplicate assignation on the same variable?
There was a problem hiding this comment.
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 |
|
/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.
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.
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.
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.
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.
Trying this here: #1812
One test is failing, to check.
Standard migration, reused #1353 (Unfinished migration to v16.0)