changeset 1a53df5aa5f7 in modules/product_cost_fifo:5.2
details: 
https://hg.tryton.org/modules/product_cost_fifo?cmd=changeset;node=1a53df5aa5f7
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 4f0fb1562d19 -r 1a53df5aa5f7 move.py
--- a/move.py   Fri Oct 11 11:44:56 2019 +0200
+++ b/move.py   Thu Oct 24 18:57:55 2019 +0200
@@ -68,8 +68,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
@@ -78,7 +81,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