diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py
index 305f9134c9c..9d9c58b3aec 100644
--- a/addons/stock/models/stock_inventory.py
+++ b/addons/stock/models/stock_inventory.py
@@ -69,6 +69,9 @@ class Inventory(models.Model):
help="Specify Products to focus your inventory on particular Products.")
start_empty = fields.Boolean('Empty Inventory',
help="Allows to start with an empty inventory.")
+ prefill_counted_quantity = fields.Boolean('Pre-fill counted quantity',
+ help='Pre-fill the counted quantity with on hand quantity for all the '
+ 'products included in the inventory adjustment.', default=True)
def unlink(self):
for inventory in self:
@@ -231,6 +234,8 @@ class Inventory(models.Model):
for void_field in [item[0] for item in product_data.items() if item[1] is None]:
product_data[void_field] = False
product_data['theoretical_qty'] = product_data['product_qty']
+ if not self.prefill_counted_quantity:
+ product_data['product_qty'] = 0
if product_data['product_id']:
product_data['product_uom_id'] = Product.browse(product_data['product_id']).uom_id.id
quant_products |= Product.browse(product_data['product_id'])
diff --git a/addons/stock/tests/test_inventory.py b/addons/stock/tests/test_inventory.py
index 66f1048f019..f06e9f033ef 100644
--- a/addons/stock/tests/test_inventory.py
+++ b/addons/stock/tests/test_inventory.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.exceptions import ValidationError
-from odoo.tests.common import SavepointCase
+from odoo.tests.common import Form, SavepointCase
class TestInventory(SavepointCase):
@@ -311,6 +311,21 @@ class TestInventory(SavepointCase):
self.assertEqual(len(inventory.line_ids), 1)
self.assertEqual(inventory.line_ids.theoretical_qty, 2)
+ def test_inventory_8(self):
+ """ Check inventory lines product quantity is 0 when inventory is
+ started with `prefill_counted_quantity` disable.
+ """
+ inventory_form = Form(self.env['stock.inventory'].with_context(
+ default_prefill_counted_quantity=False,
+ ), view='stock.view_inventory_form')
+ inventory = inventory_form.save()
+ inventory.action_start()
+ self.assertNotEqual(len(inventory.line_ids), 0)
+ # Checks all inventory lines quantities are correctly set.
+ for line in inventory.line_ids:
+ self.assertEqual(line.product_qty, 0)
+ self.assertNotEqual(line.theoretical_qty, 0)
+
def test_inventory_outdate_1(self):
""" Checks that inventory adjustment line is marked as outdated after
its corresponding quant is modify and its value was correctly updated
diff --git a/addons/stock/views/stock_inventory_views.xml b/addons/stock/views/stock_inventory_views.xml
index 833085b8225..226a32844ca 100644
--- a/addons/stock/views/stock_inventory_views.xml
+++ b/addons/stock/views/stock_inventory_views.xml
@@ -181,6 +181,8 @@