[10.0][FIX] stock_inventory_revaluation: unable to revaluate multiple quants with real method

This commit is contained in:
Cédric Pigeon
2018-10-01 10:03:34 +02:00
committed by Matt Taylor
parent e525dc4a61
commit 048f6e68f3
3 changed files with 36 additions and 4 deletions

View File

@@ -9,7 +9,7 @@
"name": "Stock Inventory Revaluation",
"summary": "Introduces inventory revaluation as single point to change "
"the valuation of products.",
"version": "10.0.1.0.0",
"version": "10.0.1.1.0",
"author": "Eficent Business and IT Consulting Services S.L., "
"Serpent Consulting Services Pvt. Ltd.,"
"Odoo Community Association (OCA)",

View File

@@ -271,9 +271,9 @@ class StockInventoryRevaluation(models.Model):
if self.product_id:
amount_diff = 0.0
if self.product_id.cost_method == 'real':
if self.reval_quant_ids:
if self.reval_quant_ids.product_id == self.product_id:
amount_diff += self.reval_quant_ids.get_total_value()
for reval_quant in self.reval_quant_ids:
if reval_quant.product_id == self.product_id:
amount_diff += reval_quant.get_total_value()
if amount_diff == 0.0:
return True
else:

View File

@@ -393,3 +393,35 @@ class TestStockInventoryRevaluation(TransactionCase):
self.assertEqual(len(
invent_price_change_real.account_move_ids), 0,
'Accounting entries have not been removed after cancel')
def test_inventory_revaluation_price_change_real_multi_quant(self):
"""Test that the inventory is revaluated when the
inventory price for a product managed under real costing method is
changed even if they are multple quant to revaluate"""
# Create an Inventory Revaluation for real cost product
location = self.env.ref('stock.stock_location_components')
self._update_product_qty(self.product_real_1, location, 1)
revaluation_type = 'price_change'
invent_price_change_real = \
self._create_inventory_revaluation(
revaluation_type,
self.product_real_1)
# Create an Inventory Revaluation Line Quant
date_from = date.today() - timedelta(1)
self._get_quant(date_from, invent_price_change_real)
invent_price_change_real.sudo(self.user1).button_post()
expected_result = (10.00 - 8.00) * 11.00
self.assertEqual(len(
invent_price_change_real.account_move_ids[0].line_ids), 2,
'Incorrect accounting entry generated')
for move_line in invent_price_change_real.account_move_ids[0].line_ids:
if move_line.account_id == self.account_inventory:
self.assertEqual(move_line.credit, expected_result,
'Incorrect inventory revaluation for '
'type Price Change.')