diff --git a/stock_inventory_discrepancy/README.rst b/stock_inventory_discrepancy/README.rst
index 581b1d00c059..c19afc7f83c5 100644
--- a/stock_inventory_discrepancy/README.rst
+++ b/stock_inventory_discrepancy/README.rst
@@ -28,9 +28,9 @@ Stock Inventory Discrepancy
|badge1| |badge2| |badge3| |badge4| |badge5|
-Adds the capability to show the discrepancy of every line in an inventory and
-to block the inventory validation (setting it as 'Pending to Approve') when the
-discrepancy is greater than an user defined threshold.
+This module adds the capability to show discrepancies for each line in an inventory and
+to block inventory validation (setting it as 'Pending to Approve') when the discrepancy
+exceeds a user-defined threshold. This is configurable per company through the settings.
Only new group "Validate All inventory Adjustments" will be able to force the
validation of those blocked inventories. By default, Stock manager will belong
@@ -45,6 +45,7 @@ threshold now.
Configuration
=============
+#. Go to "Inventory > Settings" and select the 'Inventory Discrepancy Control' option to block the inventory validation. This should be done for each company.
#. Go to "Inventory > Warehouse Management" > Warehouses" or to "Inventory >
Warehouse Management" > Locations".
#. Modify the "Maximum Discrepancy Rate Threshold" either in a Warehouse or
diff --git a/stock_inventory_discrepancy/__manifest__.py b/stock_inventory_discrepancy/__manifest__.py
index c3fa9c8c26bf..69148dfdb7fc 100644
--- a/stock_inventory_discrepancy/__manifest__.py
+++ b/stock_inventory_discrepancy/__manifest__.py
@@ -17,6 +17,7 @@
"views/stock_quant_view.xml",
"views/stock_warehouse_view.xml",
"views/stock_location_view.xml",
+ "views/res_config_settings_view.xml",
"wizards/confirm_discrepancy_wiz.xml",
],
"license": "AGPL-3",
diff --git a/stock_inventory_discrepancy/models/__init__.py b/stock_inventory_discrepancy/models/__init__.py
index cc20d5da4779..5a851da8aa7e 100644
--- a/stock_inventory_discrepancy/models/__init__.py
+++ b/stock_inventory_discrepancy/models/__init__.py
@@ -1,5 +1,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+from . import res_company
+from . import res_config_settings
from . import stock_quant
from . import stock_warehouse
from . import stock_location
diff --git a/stock_inventory_discrepancy/models/res_company.py b/stock_inventory_discrepancy/models/res_company.py
new file mode 100644
index 000000000000..14691c12663b
--- /dev/null
+++ b/stock_inventory_discrepancy/models/res_company.py
@@ -0,0 +1,14 @@
+# Copyright 2024 Quartile
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from odoo import fields, models
+
+
+class ResCompany(models.Model):
+ _inherit = "res.company"
+
+ inventory_discrepancy_enable = fields.Boolean(
+ string="Inventory Discrepancy Control",
+ help="Block validation of the inventory adjustment if discrepancy exceeds "
+ "the threshold.",
+ )
diff --git a/stock_inventory_discrepancy/models/res_config_settings.py b/stock_inventory_discrepancy/models/res_config_settings.py
new file mode 100644
index 000000000000..a8b02c2fb965
--- /dev/null
+++ b/stock_inventory_discrepancy/models/res_config_settings.py
@@ -0,0 +1,16 @@
+# Copyright 2024 Quartile
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
+
+from odoo import fields, models
+
+
+class ResConfigSettings(models.TransientModel):
+ _inherit = "res.config.settings"
+
+ inventory_discrepancy_enable = fields.Boolean(
+ related="company_id.inventory_discrepancy_enable",
+ readonly=False,
+ string="Inventory Discrepancy Control",
+ help="Block validation of the inventory adjustment if discrepancy exceeds "
+ "the threshold.",
+ )
diff --git a/stock_inventory_discrepancy/models/stock_quant.py b/stock_inventory_discrepancy/models/stock_quant.py
index 2674848b3e1d..e656955fb5ca 100644
--- a/stock_inventory_discrepancy/models/stock_quant.py
+++ b/stock_inventory_discrepancy/models/stock_quant.py
@@ -76,6 +76,8 @@ def _compute_has_over_discrepancy(self):
def action_apply_inventory(self):
if self.env.context.get("skip_exceeded_discrepancy", False):
return super().action_apply_inventory()
+ if not self.env.company.inventory_discrepancy_enable:
+ return super().action_apply_inventory()
over_discrepancy = self.filtered(lambda r: r.has_over_discrepancy)
if over_discrepancy:
action = self.env["ir.actions.act_window"]._for_xml_id(
diff --git a/stock_inventory_discrepancy/readme/CONFIGURE.rst b/stock_inventory_discrepancy/readme/CONFIGURE.rst
index 9d5628d89493..1786092ae28b 100644
--- a/stock_inventory_discrepancy/readme/CONFIGURE.rst
+++ b/stock_inventory_discrepancy/readme/CONFIGURE.rst
@@ -1,3 +1,4 @@
+#. Go to "Inventory > Settings" and select the 'Inventory Discrepancy Control' option to block the inventory validation. This should be done for each company.
#. Go to "Inventory > Warehouse Management" > Warehouses" or to "Inventory >
Warehouse Management" > Locations".
#. Modify the "Maximum Discrepancy Rate Threshold" either in a Warehouse or
diff --git a/stock_inventory_discrepancy/readme/DESCRIPTION.rst b/stock_inventory_discrepancy/readme/DESCRIPTION.rst
index 9dbe855774bb..f92817107a75 100644
--- a/stock_inventory_discrepancy/readme/DESCRIPTION.rst
+++ b/stock_inventory_discrepancy/readme/DESCRIPTION.rst
@@ -1,6 +1,6 @@
-Adds the capability to show the discrepancy of every line in an inventory and
-to block the inventory validation (setting it as 'Pending to Approve') when the
-discrepancy is greater than an user defined threshold.
+This module adds the capability to show discrepancies for each line in an inventory and
+to block inventory validation (setting it as 'Pending to Approve') when the discrepancy
+exceeds a user-defined threshold. This is configurable per company through the settings.
Only new group "Validate All inventory Adjustments" will be able to force the
validation of those blocked inventories. By default, Stock manager will belong
diff --git a/stock_inventory_discrepancy/static/description/index.html b/stock_inventory_discrepancy/static/description/index.html
index 1fa78ef401c4..a2aedd175894 100644
--- a/stock_inventory_discrepancy/static/description/index.html
+++ b/stock_inventory_discrepancy/static/description/index.html
@@ -8,11 +8,10 @@
/*
:Author: David Goodger (goodger@python.org)
-:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
+:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
-Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }
-pre.code .ln { color: gray; } /* line numbers */
+pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@
span.pre {
white-space: pre }
-span.problematic, pre.problematic {
+span.problematic {
color: red }
span.section-subtitle {
@@ -370,9 +369,9 @@
Adds the capability to show the discrepancy of every line in an inventory and
-to block the inventory validation (setting it as ‘Pending to Approve’) when the
-discrepancy is greater than an user defined threshold.
+
This module adds the capability to show discrepancies for each line in an inventory and
+to block inventory validation (setting it as ‘Pending to Approve’) when the discrepancy
+exceeds a user-defined threshold. This is configurable per company through the settings.
Only new group “Validate All inventory Adjustments” will be able to force the
validation of those blocked inventories. By default, Stock manager will belong
to this group. In addition, Stock Users can validate inventories under the
@@ -394,6 +393,7 @@
Go to “Inventory > Settings” and select the ‘Inventory Discrepancy Control’ option to block the inventory validation. This should be done for each company.
Go to “Inventory > Warehouse Management” > Warehouses” or to “Inventory >
Warehouse Management” > Locations”.
Modify the “Maximum Discrepancy Rate Threshold” either in a Warehouse or
@@ -446,9 +446,7 @@
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.