Add a fix to recompute_cost_price.diff.

This commit is contained in:
Albert Cervera i Areny 2017-09-19 11:13:23 +02:00
parent 6f960a3b4f
commit 38ce86bffa
1 changed files with 18 additions and 0 deletions

View File

@ -19,3 +19,21 @@ diff -r 4c5035111f5f trytond/trytond/modules/stock/product.py
move.company.currency, round=False)
unit_price = Uom.compute_price(move.uom, unit_price,
self.default_uom)
diff -r f7364566b2de product.py
--- a/trytond/trytond/modules/stock/product.py Tue Aug 08 18:37:48 2017 +0200
+++ b/trytond/trytond/modules/stock/product.py Tue Sep 19 10:57:02 2017 +0200
@@ -267,10 +267,12 @@
move.company.currency, round=False)
unit_price = Uom.compute_price(move.uom, unit_price,
self.default_uom)
- if quantity + qty != 0:
+ acc_quantity = max(quantity, 0)
+ move_quantity = max(qty, 0)
+ if acc_quantity + move_quantity != 0:
cost_price = (
- (cost_price * quantity) + (unit_price * qty)
- ) / (quantity + qty)
+ (cost_price * acc_quantity) + (unit_price * move_quantity)
+ ) / (acc_quantity + move_quantity)
quantity += qty
return cost_price