From fdef30fc2995d182fe779a777fb42ba1066c2cac Mon Sep 17 00:00:00 2001
From: Christophe Simonis <chs@odoo.com>
Date: Tue, 17 Apr 2018 15:27:18 +0200
Subject: [PATCH] [FIX] purchase: ignore quantity sign when computing move
 amount_currency

Since 348c371ee859f7ce4d0d5d3f84827d21639d1656, the quantity is negative
for out moves. Ignore the sign when computing the amount_currency value.
---
 addons/purchase/models/stock.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/addons/purchase/models/stock.py b/addons/purchase/models/stock.py
index 6d06186b87d4..b03885067676 100644
--- a/addons/purchase/models/stock.py
+++ b/addons/purchase/models/stock.py
@@ -56,12 +56,11 @@ class StockMove(models.Model):
         self.ensure_one()
 
         rslt = super(StockMove, self)._generate_valuation_lines_data(partner_id, qty, debit_value, credit_value, debit_account_id, credit_account_id)
-
         if self.purchase_line_id:
             purchase_currency = self.purchase_line_id.currency_id
             if purchase_currency != self.company_id.currency_id:
                 purchase_price_unit = self.purchase_line_id.price_unit
-                currency_move_valuation = purchase_currency.round(purchase_price_unit * qty)
+                currency_move_valuation = purchase_currency.round(purchase_price_unit * abs(qty))
                 rslt['credit_line_vals']['amount_currency'] = rslt['credit_line_vals']['credit'] and -currency_move_valuation or currency_move_valuation
                 rslt['credit_line_vals']['currency_id'] = purchase_currency.id
                 rslt['debit_line_vals']['amount_currency'] = rslt['debit_line_vals']['credit'] and -currency_move_valuation or currency_move_valuation
-- 
GitLab