odoo/odoo#170414

Created by fw-bot
Merged at a2fdb638da4e5dd13612352444c4db6f782dcbea

Statuses:

label
odoo-dev:saas-17.1-17.0-opw-3940786-Buy_MTO_variant_sensitive-lase-Idm1-fw
head
4c4761a92c55917bf58d5f5bd1d163a64b25c9b2
merged
2 years ago by Bugfix, Lancelot Semal (lase)
odoo/odoo
17.0 #166970
saas-17.1 #170414
saas-17.2 #170441
saas-17.3 #170498
18.0
saas-18.2
saas-18.3
saas-18.4
19.0
saas-19.1
saas-19.2
master #170525

[FW][FIX] product: assign seller depending on variant value

Steps to reproduce:

Expected behavior:

Two purchase order should be created:

Current behavior:

Only one purchase order is created so that Vendor 1 as the seller of both procurements even thought vendor 2 is the only real potential seller of the white variant.

Cause of the issue:

Running the procurements of both lines of the Sale order will trigger the _run_buy method which will determine the seller by "default": https://github.com/odoo/odoo/blob/3383d5bd68bfc13b7881f72e5adbb7c27a6df30e/addons/purchase_stock/models/stock_rule.py#L70-L72 using the _prepare_sellers method. However, it relies solely on the seller_ids field of the product.template model https://github.com/odoo/odoo/blob/3383d5bd68bfc13b7881f72e5adbb7c27a6df30e/addons/product/models/product_product.py#L633-L634 Since both variants have the same template they will therefore both be associated with the same default seller.

opw-3940786

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

Forward-Port-Of: #166970