changeset bbbefe975064 in modules/product_cost_fifo:5.0
details: 
https://hg.tryton.org/modules/product_cost_fifo?cmd=changeset;node=bbbefe975064
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 200f2d6ba9eb -r bbbefe975064 move.py
--- a/move.py   Fri Oct 11 11:44:56 2019 +0200
+++ b/move.py   Thu Oct 24 18:57:55 2019 +0200
@@ -69,8 +69,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
@@ -79,7 +82,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])))

Reply via email to