diff --git a/CHANGELOG b/CHANGELOG index 3fe4d0b697..bd7d21a9bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Use the purchase uom to compute purchase price from product supplier * Add buttons to handle invoice and packing exceptions * Allow egg installation diff --git a/purchase.py b/purchase.py index c68f54e381..64111b59db 100644 --- a/purchase.py +++ b/purchase.py @@ -1323,18 +1323,22 @@ class Product(ModelSQL, ModelView): for product in self.browse(cursor, user, ids, context=context): res[product.id] = product.cost_price + default_uom = product.default_uom + if not uom: + uom = default_uom if context.get('supplier') and product.product_suppliers: supplier_id = context['supplier'] for product_supplier in product.product_suppliers: if product_supplier.party.id == supplier_id: for price in product_supplier.prices: - if price.quantity <= quantity: + if uom_obj.compute_qty(cursor, user, + product.purchase_uom, price.quantity, uom, + context=context) <= quantity: res[product.id] = price.unit_price + default_uom = product.purchase_uom break - if uom: - res[product.id] = uom_obj.compute_price(cursor, - user, product.default_uom, res[product.id], - uom, context=context) + res[product.id] = uom_obj.compute_price(cursor, user, + default_uom, res[product.id], uom, context=context) if currency and user2.company: if user2.company.currency.id != currency.id: res[product.id] = currency_obj.compute(cursor, user,