[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
This commit is contained in:
Hetashree Chauhan
2019-07-24 09:35:37 +00:00
committed by Simon Lejeune
parent 66c49dd451
commit 33c636cf28
+3 -4
View File
@@ -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 ...