diff --git a/addons/stock_account/tests/test_stockvaluation.py b/addons/stock_account/tests/test_stockvaluation.py index cdeb2156375..27fefc06df0 100644 --- a/addons/stock_account/tests/test_stockvaluation.py +++ b/addons/stock_account/tests/test_stockvaluation.py @@ -4048,3 +4048,22 @@ class TestStockValuation(TestStockValuationBase): with self.assertRaises(UserError): revaluation.action_validate_revaluation() + + def test_manual_revaluation_statement(self): + self.product1.categ_id.property_cost_method = 'fifo' + self.product1.categ_id.property_valuation = 'real_time' + + self._make_in_move(self.product1, 1, unit_cost=15) + + revaluation_form = Form(self.env['stock.valuation.layer.revaluation'].with_context({ + 'default_product_id': self.product1.id, + 'default_company_id': self.env.company.id, + })) + revaluation_form.added_value = 10.0 + revaluation_form.account_id = self.stock_valuation_account + revaluation = revaluation_form.save() + revaluation.action_validate_revaluation() + + account_move = self.env['account.move'].search([('journal_id', '=', revaluation.account_journal_id.id)]) + + self.assertEqual(account_move.line_ids[0].name, 'OdooBot changed stock valuation from 15.0 to 25.0 - [prda] Product A') diff --git a/addons/stock_account/wizard/stock_valuation_layer_revaluation.py b/addons/stock_account/wizard/stock_valuation_layer_revaluation.py index e46927e1efc..5f71ebf16a0 100644 --- a/addons/stock_account/wizard/stock_valuation_layer_revaluation.py +++ b/addons/stock_account/wizard/stock_valuation_layer_revaluation.py @@ -107,6 +107,7 @@ class StockValuationLayerRevaluation(models.TransientModel): remaining_value -= taken_remaining_value remaining_qty -= svl.remaining_qty + previous_value_svl = self.current_value_svl revaluation_svl = self.env['stock.valuation.layer'].create(revaluation_svl_vals) # Update the stardard price in case of AVCO/FIFO @@ -136,8 +137,8 @@ class StockValuationLayerRevaluation(models.TransientModel): 'line_ids': [(0, 0, { 'name': _('%(user)s changed stock valuation from %(previous)s to %(new_value)s - %(product)s', user=self.env.user.name, - previous=self.current_value_svl, - new_value=self.current_value_svl + self.added_value, + previous=previous_value_svl, + new_value=previous_value_svl + self.added_value, product=product_id.display_name, ), 'account_id': debit_account_id, @@ -147,8 +148,8 @@ class StockValuationLayerRevaluation(models.TransientModel): }), (0, 0, { 'name': _('%(user)s changed stock valuation from %(previous)s to %(new_value)s - %(product)s', user=self.env.user.name, - previous=self.current_value_svl, - new_value=self.current_value_svl + self.added_value, + previous=previous_value_svl, + new_value=previous_value_svl + self.added_value, product=product_id.display_name, ), 'account_id': credit_account_id,