diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py
index 638e39e4d09747f2f92039cb09683e2b37540483..e9888e6b49b803b3ecd2389615a1ac35c4d9eaf5 100644
--- a/addons/stock_account/models/product.py
+++ b/addons/stock_account/models/product.py
@@ -487,6 +487,7 @@ class ProductProduct(models.Model):
                     'credit': abs(value),
                     'product_id': product.id,
                 })],
+                'type': 'entry',
             }
             move_vals_list.append(move_vals)
         return move_vals_list
@@ -522,6 +523,7 @@ class ProductProduct(models.Model):
                     'credit': abs(value),
                     'product_id': product.id,
                 })],
+                'type': 'entry',
             }
             move_vals_list.append(move_vals)
         return move_vals_list
diff --git a/addons/stock_account/tests/test_stockvaluationlayer.py b/addons/stock_account/tests/test_stockvaluationlayer.py
index 1dd1a9fc28319a08a54b0ef71aacdeeee4f5a9dc..cd9098c03846224c0b82e774b979005a60d4a0b4 100644
--- a/addons/stock_account/tests/test_stockvaluationlayer.py
+++ b/addons/stock_account/tests/test_stockvaluationlayer.py
@@ -778,7 +778,10 @@ class TestStockValuationChangeValuation(TestStockValuationCommon):
             'property_stock_journal': self.stock_journal.id,
         })
 
-        self.product1.categ_id = cat2
+        # Try to change the product category with a `default_type` key in the context and
+        # check it doesn't break the account move generation.
+        self.product1.with_context(default_type='product').categ_id = cat2
+        self.assertEqual(self.product1.categ_id, cat2)
 
         self.assertEqual(self.product1.value_svl, 100)
         self.assertEqual(self.product1.quantity_svl, 10)