[FIX] stock_account: No returned value for function _run_valuation

This commit 9eac6c6377 expects a returned value
from function called "_run_valuation".

But this function always returned None.

opw:1907021

closes odoo/odoo#29302
This commit is contained in:
Goffin Simon
2018-12-06 09:45:09 +00:00
parent b750c78b91
commit 4612d50bae
+9 -4
View File
@@ -306,18 +306,20 @@ class StockMove(models.Model):
vals = {} vals = {}
price_unit = self._get_price_unit() price_unit = self._get_price_unit()
value = price_unit * (quantity or valued_quantity) value = price_unit * (quantity or valued_quantity)
value_to_return = value if quantity is None or not self.value else self.value
vals = { vals = {
'price_unit': price_unit, '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, '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 vals['remaining_qty'] = valued_quantity if quantity is None else self.remaining_qty + quantity
if self.product_id.cost_method == 'standard': if self.product_id.cost_method == 'standard':
value = self.product_id.standard_price * (quantity or valued_quantity) 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({ vals.update({
'price_unit': self.product_id.standard_price, '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) self.write(vals)
elif self._is_out(): elif self._is_out():
@@ -329,8 +331,9 @@ class StockMove(models.Model):
if self.product_id.cost_method in ['standard', 'average']: if self.product_id.cost_method in ['standard', 'average']:
curr_rounding = self.company_id.currency_id.rounding 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 = -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({ self.write({
'value': value if quantity is None else self.value + value, 'value': value_to_return,
'price_unit': value / valued_quantity, 'price_unit': value / valued_quantity,
}) })
elif self._is_dropshipped() or self._is_dropshipped_returned(): elif self._is_dropshipped() or self._is_dropshipped_returned():
@@ -342,12 +345,14 @@ class StockMove(models.Model):
else: else:
price_unit = self.product_id.standard_price price_unit = self.product_id.standard_price
value = float_round(self.product_qty * price_unit, precision_rounding=curr_rounding) 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 # In move have a positive value, out move have a negative value, let's arbitrary say
# dropship are positive. # dropship are positive.
self.write({ 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, 'price_unit': price_unit if self._is_dropshipped() else -price_unit,
}) })
return value_to_return
def _action_done(self): def _action_done(self):
self.product_price_update_before_done() self.product_price_update_before_done()