changeset f417bd4a0b59 in modules/account_invoice_stock:default
details: 
https://hg.tryton.org/modules/account_invoice_stock?cmd=changeset&node=f417bd4a0b59
description:
        Add back the shipment cost when recompute move unit price

        When the unit price of a move is updated, the shipment cost that was 
added must
        be added back.

        issue10196
        review348201004
diffstat:

 stock.py |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (30 lines):

diff -r 53918955ac8b -r f417bd4a0b59 stock.py
--- a/stock.py  Sun Mar 21 16:07:45 2021 +0100
+++ b/stock.py  Wed Apr 28 00:35:04 2021 +0200
@@ -93,12 +93,13 @@
     def update_unit_price(cls, moves):
         for move in moves:
             if move.state == 'done':
-                unit_price = move._compute_unit_price()
+                unit_price = move._compute_unit_price(
+                    unit_price=move.unit_price)
                 if unit_price != move.unit_price:
                     move.unit_price = unit_price
         cls.save(moves)
 
-    def _compute_unit_price(self):
+    def _compute_unit_price(self, unit_price):
         pool = Pool()
         UoM = pool.get('product.uom')
         Currency = pool.get('currency.currency')
@@ -111,9 +112,7 @@
                 if line.invoice.type == 'out' or not line.correction:
                     quantity += UoM.compute_qty(
                         line.unit, line.quantity, self.uom)
-        if not quantity:
-            unit_price = self.unit_price
-        else:
+        if quantity:
             unit_price = round_price(amount / Decimal(str(quantity)))
         return unit_price
 

Reply via email to