summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Pinna Puissant <jpp@odoo.com>2020-05-20 09:14:47 +0000
committerJorge Pinna Puissant <jpp@odoo.com>2020-05-27 06:22:15 +0000
commitc25f4359942a9ee0035cb08bc69a0c25c6f8258f (patch)
tree80f6a3ee189c146bfac95ef73a3cf3e4c4c3e012
parent148f3dabc91fbb59ae5abe6396ca614a708577b9 (diff)
[FIX] purchase_stock: vendor choice in multi-company
- Set two companies (A and B); - Set intercompany flows enabled between company A and B with synchronization of PO/SO; - create a product X is configured as follows in company B: - Storable product; - Routes “Buy” and “Dropship”; - Vendors price list set with vendor = company A. - Product X is configured as follows in company A: - Storable product; - Reordering rule Min 0 / Max 0; - Route “Buy”; - Vendors price list set with vendor = 'External Vendor'. - Create and validate a sale order for product X to final customer within company B; Odoo will automatically create a purchase order for product X to company A within company B; - Validate the purchase order in company B; Odoo will automatically create a sale order for product X to company B within company A; - If there is no available stock in warehouse A; Odoo will automatically create a purchase order for product X within company A. Before this commit, the purchase order is created with vendor as 'Company A'. As '_select_seller' is run in sudo mode (see: https://github.com/odoo/odoo/blob/a16c4a0dabe58ab2cfade353c113387ae5bcd572/addons/stock/models/stock_rule.py#L458), so is not company-aware, therefore the first matching supplier is chosen. Now, the purchase order will be created with vendor as 'External Vendor'. opw-2255989 closes odoo/odoo#51596 closes odoo/odoo#51908 X-original-commit: e2dd8ea7544fba659810ba829433fce7099c1d40 Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
-rw-r--r--addons/purchase_stock/models/stock_rule.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/purchase_stock/models/stock_rule.py b/addons/purchase_stock/models/stock_rule.py
index b10cd241544..620f8b087e3 100644
--- a/addons/purchase_stock/models/stock_rule.py
+++ b/addons/purchase_stock/models/stock_rule.py
@@ -54,7 +54,7 @@ class StockRule(models.Model):
if procurement.values.get('supplierinfo_id'):
supplier = procurement.values['supplierinfo_id']
else:
- supplier = procurement.product_id._select_seller(
+ supplier = procurement.product_id.with_company(procurement.company_id.id)._select_seller(
partner_id=procurement.values.get("supplierinfo_name"),
quantity=procurement.product_qty,
date=schedule_date.date(),