trytond-patches/issue154_316.diff
Bernat Brunet Torruella ff90fad934 Update path patches
2015-02-19 10:21:09 +01:00

37 lines
1.7 KiB
Diff

diff -r ae376b988766 product.py
--- .a/trytond/trytond/modules/purchase/product.py Mon Oct 20 15:02:51 2014 +0200
+++ .b/trytond/trytond/modules/purchase/product.py Mon Nov 03 13:24:24 2014 +0100
@@ -132,11 +132,14 @@
for product_supplier in product.product_suppliers:
if product_supplier.match(pattern):
pattern = ProductSupplierPrice.get_pattern()
- for price in product_supplier.prices:
- if price.match(quantity, uom, pattern):
- prices[product.id] = price.unit_price
- default_uom = product_supplier.uom
- default_currency = product_supplier.currency
+ price = product.get_supplier_price(product_supplier,
+ quantity, uom, pattern)
+ if price is not None:
+ prices[product.id] = price
+ default_uom = product.purchase_uom
+ default_currency = product_supplier.currency
+ else:
+ price = product.cost_price
break
prices[product.id] = Uom.compute_price(
default_uom, prices[product.id], uom)
@@ -147,6 +150,13 @@
prices[product.id], currency, round=False)
return prices
+ def get_supplier_price(self, product_supplier, quantity, uom, pattern):
+ res = None
+ for price in product_supplier.prices:
+ if price.match(quantity, uom, pattern):
+ res = price.unit_price
+ return res
+
class ProductSupplier(ModelSQL, ModelView, MatchMixin):
'Product Supplier'