From fdc20d13bb6c4f22bcfcf88384f8a13a2cb4b005 Mon Sep 17 00:00:00 2001 From: Carlos Dauden Date: Tue, 16 Jun 2020 11:35:05 +0000 Subject: [PATCH] [FIX] sale_purchase: Take into account minimal quantity supplierinfo closes odoo/odoo#53548 X-original-commit: d872cbf11f05cd10aa9b36b3c0aded895e0e68f3 Signed-off-by: Arnold Moyaux --- addons/sale_purchase/models/sale_order.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/sale_purchase/models/sale_order.py b/addons/sale_purchase/models/sale_order.py index 36fd34699c7..55055be07a2 100644 --- a/addons/sale_purchase/models/sale_order.py +++ b/addons/sale_purchase/models/sale_order.py @@ -266,8 +266,7 @@ class SaleOrderLine(models.Model): for line in self: line = line.with_company(line.company_id) # determine vendor of the order (take the first matching company and product) - # VFE fixme why isn't the _select_seller function used ??? - suppliers = line.product_id.seller_ids.filtered(lambda vendor: (not vendor.company_id or vendor.company_id == line.company_id) and (not vendor.product_id or vendor.product_id == line.product_id)) + suppliers = line.product_id._select_seller(quantity=line.product_uom_qty, uom_id=line.product_uom) if not suppliers: raise UserError(_("There is no vendor associated to the product %s. Please define a vendor for this product.") % (line.product_id.display_name,)) supplierinfo = suppliers[0]