summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHetashree Chauhan <hch@odoo.com>2019-06-10 09:40:11 +0000
committerSimon Lejeune <sle@openerp.com>2019-07-24 09:35:37 +0000
commit33c636cf28a99e3f737b41ddfc990478dd7b1ffa (patch)
treeb5c8a4ef5a3016523f199b38b57842e881e2cd5b
parent66c49dd451e8debdb3d28c22cda0d4e80b383501 (diff)
[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
-rw-r--r--addons/product/models/product.py7
1 files 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 ...