From 4612d50bae8a4d8d6ef1e853732ad4cf5af1a9fb Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 6 Dec 2018 09:42:58 +0000 Subject: [PATCH] [FIX] stock_account: No returned value for function _run_valuation This commit 9eac6c63773bf0b744aa9e2f5bbec5a2a03ae60d expects a returned value from function called "_run_valuation". But this function always returned None. opw:1907021 closes odoo/odoo#29302 --- addons/stock_account/models/stock.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index eb34f637c9e..8a8e2df8c9c 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -306,18 +306,20 @@ class StockMove(models.Model): vals = {} price_unit = self._get_price_unit() value = price_unit * (quantity or valued_quantity) + value_to_return = value if quantity is None or not self.value else self.value vals = { 'price_unit': price_unit, - 'value': value if quantity is None or not self.value else self.value, + 'value': value_to_return, 'remaining_value': value if quantity is None else self.remaining_value + value, } vals['remaining_qty'] = valued_quantity if quantity is None else self.remaining_qty + quantity if self.product_id.cost_method == 'standard': value = self.product_id.standard_price * (quantity or valued_quantity) + value_to_return = value if quantity is None or not self.value else self.value vals.update({ 'price_unit': self.product_id.standard_price, - 'value': value if quantity is None or not self.value else self.value, + 'value': value_to_return, }) self.write(vals) elif self._is_out(): @@ -329,8 +331,9 @@ class StockMove(models.Model): if self.product_id.cost_method in ['standard', 'average']: curr_rounding = self.company_id.currency_id.rounding value = -float_round(self.product_id.standard_price * (valued_quantity if quantity is None else quantity), precision_rounding=curr_rounding) + value_to_return = value if quantity is None else self.value + value self.write({ - 'value': value if quantity is None else self.value + value, + 'value': value_to_return, 'price_unit': value / valued_quantity, }) elif self._is_dropshipped() or self._is_dropshipped_returned(): @@ -342,12 +345,14 @@ class StockMove(models.Model): else: price_unit = self.product_id.standard_price value = float_round(self.product_qty * price_unit, precision_rounding=curr_rounding) + value_to_return = value if self._is_dropshipped() else -value # In move have a positive value, out move have a negative value, let's arbitrary say # dropship are positive. self.write({ - 'value': value if self._is_dropshipped() else -value, + 'value': value_to_return, 'price_unit': price_unit if self._is_dropshipped() else -price_unit, }) + return value_to_return def _action_done(self): self.product_price_update_before_done()