[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>
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user