[FIX] purchase: ignore quantity sign when computing move amount_currency

Since 348c371ee8, the quantity is negative
for out moves. Ignore the sign when computing the amount_currency value.
This commit is contained in:
Christophe Simonis
2018-04-17 15:30:02 +02:00
parent ab6c3f66a3
commit fdef30fc29
+1 -2
View File
@@ -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