odoo/odoo#189272

Created by Guillaume Teboul-Tornezy (gute)
Merged at 62eee7fa22a7a3a57ca84f4949f970cfbc027223

Statuses:

label
odoo-dev:17.0-opw-4347134-vendor_price_po-gute
head
4cf4f4f4d3086c5a55bac59f8c4c9a433b2002d7
merged
9 months ago by Logistics, William Henrotin (whe)
odoo/odoo
17.0 #189272
saas-17.2 #192871
saas-17.4 #192889
18.0 #192918
saas-18.1 #193361
saas-18.2
saas-18.3
saas-18.4
19.0
master #193378

[FIX] purchase: set_vendor_price_po_company

The issue:
When a vendor has multiple prices for two companies (A and B), and the purchase order's company is set to B (while the user's main company is A), the price incorrectly defaults to the main company A's price.

How to reproduce the issue:
1) Create a new product with 2 vendor pricelist records that have different "Unit Prices" under the "Purchase" tab of the product -> each pricelist record should belong to a different company

2) Create an RFQ for this product with both of these companies active

3) Change the "Company" on the PO under the "Other Information" tab to the company that is NOT shown in the top right-hand corner, but is still selected

4) Add the product to the RFQ order line
- The "Unit Price" will be pulled from the main company shown in the top-right hand corner, thereby ignoring the "Company" selected for the PO.

After this commit, the price from the purchase order's company (B) is prioritized over the main company (A).

opw-4347134


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