From 33c636cf28a99e3f737b41ddfc990478dd7b1ffa Mon Sep 17 00:00:00 2001 From: Hetashree Chauhan Date: Mon, 10 Jun 2019 09:40:11 +0000 Subject: [PATCH] [IMP] product: find best price for a vendor based on min qty. Purpose of this task: Choose a vendor with the minimum price, respecting the quantity Before commit: The system was choosing the vendor by sequence, But if there are any vendor having a different price for the same product, based on ordered quantity, then the system can't choose the lowest price. After this commit: If there are vendors having different price based on the ordered quantity, then the system will choose the vendor based on the quantity and lowest price. task-1947351 closes: https://github.com/odoo/odoo/pull/34049 --- addons/product/models/product.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 6dfd75e3b2d..5c8474a09e3 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -636,10 +636,9 @@ class ProductProduct(models.Model): continue if seller.product_id and seller.product_id != self: continue - - res |= seller - break - return res + if not res or res.name == seller.name: + res |= seller + return res.sorted('price')[:1] def price_compute(self, price_type, uom=False, currency=False, company=False): # TDE FIXME: delegate to template or not ? fields are reencoded here ...