changeset e60e09fdb5cd in modules/product_cost_fifo:4.6
details:
https://hg.tryton.org/modules/product_cost_fifo?cmd=changeset;node=e60e09fdb5cd
description:
Use current cost price if no FIFO moves
If we can not find any FIFO moves, the products should be moved out at
the
average cost price instead of zero.
issue8699
review252351002
(grafted from ea82b7ca5eb124533fdf531708f8716aafefcddd)
diffstat:
move.py | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diffs (25 lines):
diff -r c513c5678151 -r e60e09fdb5cd move.py
--- a/move.py Fri Oct 11 11:44:56 2019 +0200
+++ b/move.py Thu Oct 24 18:57:55 2019 +0200
@@ -70,8 +70,11 @@
# TODO save in do method when product change
self.__class__.save(to_save)
- if Decimal(str(consumed_qty)) != Decimal("0"):
+ if consumed_qty:
cost_price = cost_price / Decimal(str(consumed_qty))
+ else:
+ cost_price = self.product.get_multivalue(
+ 'cost_price', **self._cost_price_pattern)
# Compute average cost price
unit_price = self.unit_price
@@ -80,7 +83,7 @@
average_cost_price = self._compute_product_cost_price('out')
self.unit_price = unit_price
- if cost_price != Decimal("0"):
+ if cost_price:
digits = self.__class__.cost_price.digits
cost_price = cost_price.quantize(
Decimal(str(10.0 ** -digits[1])))