mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
37 lines
1.7 KiB
Diff
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'
|