diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py index b59255421d5..9760d87de0c 100644 --- a/addons/stock_account/models/product.py +++ b/addons/stock_account/models/product.py @@ -675,8 +675,12 @@ class ProductCategory(models.Model): continue # Empty out the stock with the current cost method. - description = _("Costing method change for product category %s: from %s to %s.") \ - % (self.display_name, self.property_cost_method, new_cost_method) + if new_cost_method: + description = _("Costing method change for product category %s: from %s to %s.") \ + % (self.display_name, self.property_cost_method, new_cost_method) + else: + description = _("Valuation method change for product category %s: from %s to %s.") \ + % (self.display_name, self.property_valuation, new_valuation) out_svl_vals_list, products_orig_quantity_svl, products = Product\ ._svl_empty_stock(description, product_category=product_category) out_stock_valuation_layers = SVL.create(out_svl_vals_list) diff --git a/addons/stock_account/tests/test_stockvaluationlayer.py b/addons/stock_account/tests/test_stockvaluationlayer.py index 58753889113..dd2d65dd75e 100644 --- a/addons/stock_account/tests/test_stockvaluationlayer.py +++ b/addons/stock_account/tests/test_stockvaluationlayer.py @@ -613,6 +613,8 @@ class TestStockValuationChangeCostMethod(TestStockValuationCommon): self.assertEqual(self.product1.quantity_svl, 19) self.assertEqual(len(self.product1.stock_valuation_layer_ids), 5) + for svl in self.product1.stock_valuation_layer_ids[-2:]: + self.assertEqual(svl.description, 'Costing method change for product category All: from standard to fifo.') def test_standard_to_fifo_2(self): """ We want the same result as `test_standard_to_fifo_1` but by changing the category of @@ -727,6 +729,8 @@ class TestStockValuationChangeValuation(TestStockValuationCommon): # An accounting entry should only be created for the replenish now that the category is perpetual. self.assertEqual(len(self.product1.stock_valuation_layer_ids.mapped('account_move_id')), 1) self.assertEqual(len(self.product1.stock_valuation_layer_ids), 3) + for svl in self.product1.stock_valuation_layer_ids[-2:]: + self.assertEqual(svl.description, 'Valuation method change for product category All: from manual_periodic to real_time.') def test_standard_manual_to_auto_2(self): self.product1.product_tmpl_id.categ_id.property_cost_method = 'standard'